*==============================================================================*
*===*                  Overconfidence and Gun Preferences                  *===*
*===*                * Summary statistics and regressions *                *===*
*===*                              * Tables *                              *===*
*==============================================================================*

* Authors: Fernando G. Cafferata, Patricio Dominguez, and Carlos Scartascini
* Code by: Andres Barinas-Forero & Matias Guizzo-Altube

*===========================================================================*
* 0. Setting 
*===========================================================================*

* Clearing memory
	clear all
	clear mata
	clear matrix
	set more off
	
	*ssc install xlincom
	
* Defining paths
	global today = strtrim(c(current_date))
	global path "C:/Users/afelipeb/OneDrive - Inter-American Development Bank Group/IADB Andres Barinas/Overconfidence_Guns/Replication Package" // This global should be changed with the personal directory in order to use the other globals (the ones are below)
	global data "$path/Data"
	global output "$path/Output"
	global tables "$path/Tables"
	global figures "$path/Figures"
	global scripts "$path/Scripts"

* Loading clean dataset
	qui run "$scripts/main_cleaning.do"
	use "$data/Crime_.dta", clear	


**===========================================================================*
* 1. Summary statistics
*============================================================================*

************************************************************************************
*  Table A.1. Summary statistics of database's variables ["task 1a" in Overleaf]
************************************************************************************
{
gen overconfident=(overestimation>0) if overestimation < .

global demographics "Female Age educ d_employed d_retired level_income d_single d_married  d_widow d_divorced Elementary HighSchool College"
global perception "trust_gov trust_pres trust_just trust_pol satisfaction" 
global overestimation "overestimation mean_trust ocon10 right_answers"
global overestimation_d "overconfident"
global overplacement "ovpl1_less ovpl1_more ovpl2_less ovpl2_eq ovpl2_more ovpl3_less ovpl3_eq ovpl3_more ovpl4_less ovpl4_eq ovpl4_more"
global guns "arm3 arm4 arm5 arm6 arm7_never arm7_knife arm7_fire arm7_alws arm8_never arm8_knife arm8_fire arm8_alws arm9_never arm9_equal arm9_alws"
global confidence_d "ocon1c_d ocon2c_d ocon3c_d ocon4c_d ocon5c_d ocon6c_d ocon7c_d ocon8c_d ocon9c_d" 

estpost sum $demographics $perception $overestimation $overestimation_d  $overplacement $overplacement_d $guns $guns_d , d
esttab . using "$tables/Table1_SS.tex", replace cells("count(fmt(0))mean(fmt(2)) sd(fmt(2)) min(fmt(2)) max(fmt(2))") 
}

***************************************************************************************************************
* Table A.2. Descriptive statistics: Gun preferences by country (Dummies) ["task 1b - table 2" in Overleaf]
***************************************************************************************************************
{
eststo X : estpost tabstat d_narm3 d_narm4 d_narm5 d_narm6 d_narm7 d_narm8 d_narm9, by(country) stat(median mean sd) 
esttab X using "$tables/Table2_SS.tex", cells("d_narm3 d_narm4 d_narm5 d_narm6 d_narm7 d_narm8 d_narm9") plain nomtitle nonumber noobs label replace 
}

*****************************************************************************
* Table A.3. Overconfidence variable distributions ["task 1c" in Overleaf]
*****************************************************************************
{
// ssc install tabout // Uncomment if command `tabout' was not previously installed
local replace "replace"
foreach v of varlist nmor1 nmor2 nmor3 nmor4 overestimation overestimation_2 {
	tabout `v' using "$tables/Table3_SS.xls", c(freq col cum) f(4) `replace' // dpcomma
		local replace "append"
}
}

************************************************************************************************************
*  Table A.4. Descriptive statistics: Overconfidence by country (Dummies) ["task 1b - table3" in Overleaf]
************************************************************************************************************
{
eststo X : estpost tabstat overestim_dummy d_nmor1 d_nmor2 d_nmor3 d_nmor4, by(country) stat(median mean sd) // format(%9.3g)
esttab X using "$tables/Table4_SS.tex", cells("overestim_dummy d_nmor1 d_nmor2 d_nmor3 d_nmor4") plain nomtitle nonumber noobs replace
}

**********************************************************************************************************************
* Table A.5. Descriptive statistics: Estimated and actual number of rights answers by country ["task 1d" in Overleaf]
***********************************************************************************************************************
{
eststo X : estpost tabstat ocon10 ocon10_c right_answers, by(country) stat(median mean sd) // format(%9.3g)
esttab X using "$tables/Table5_SS.tex", cells("ocon10 ocon10_c right_answers") plain nomtitle nonumber noobs replace
}

**************************************************************************************************************************
* Table A.6. Descriptive statistics: Percentage of overconf. individuals by country with different Overconf. Indexes ["task 1e" in Overleaf]
**************************************************************************************************************************
{
	* First, create the measure of overconfidence 2
	cap gen overconfident_2=(ocon10_c-right_answers>0)

eststo X : estpost tabstat overconfident overconfident_2, by(country) stats(mean) 
esttab X using "$tables/Table6_SS.tex", cells("overconfident overconfident_2") plain nomtitle nonumber noobs replace
}

*********************************************************************************************
* Table A.7. Correlation between Overestimation Inexes ["correlations" in Overleaf] (Slow)
*********************************************************************************************
{
* This is a REALLY inefficieny way, but I kept it as it is the one presented in the paper.
forvalues i=1(1)9{
	gen OK_Ocon_`i'_random=OK_Ocon_`i'
	gen ocon`i'c_random=(ocon`i'c>=3)
}

set seed 28145
gen a = _n
forvalues i=1(1)7276{
		preserve
		clear
		set obs 9
		gen a = _n
		gen rnd = runiform()
		sort rnd
		drop if _n<=7
		sort a
		levelsof a, local(preguntas)
		display "`preguntas'"
		restore
	foreach preg of local preguntas{
		replace OK_Ocon_`preg'_random=. if a==`i'
		replace ocon`preg'c_random=. if a==`i'
	}
}

	* Create variables for correlation index
	cap gen overcondifence_index2=ocon10_c-right_answers
	egen right_answers_random=rowtotal(OK_Ocon_1_random OK_Ocon_2_random OK_Ocon_3_random OK_Ocon_4_random OK_Ocon_5_random OK_Ocon_6_random OK_Ocon_7_random OK_Ocon_8_random OK_Ocon_9_random)
	egen ocon10_c_random=rowtotal(ocon1c_random ocon2c_random ocon3c_random ocon4c_random ocon5c_random ocon6c_random ocon7c_random ocon8c_random ocon9c_random)
	cap gen overcondifence_index_random=ocon10_c_random-right_answers_random

	
cor overestimation overcondifence_index2 overcondifence_index_random
	frmttable using "$tables/Table7_SS", ///
		statmat(r(C)) sdec(3) ///
		rti("Regulat index" \ "Alternative index" \ "Random index") ///
		cti("", "Regular index", "Alternative idnex", "Random index") ///
		tex frag replace
}
		
*********************************************************************************
* Table A.8. Individual traits of overconfidence ["overconfident" in Overleaf]
*********************************************************************************
{
eststo X1 : estpost tabstat overestimation_cat nmor1 nmor2 nmor3 nmor4, statistics(mean) by(gender)
	esttab X1 using "$tables/Table8_SS.tex", cells("overestimation_cat nmor1 nmor2 nmor3 nmor4") plain nomtitle nonumber noobs replace
eststo X2 : estpost tabstat overestimation_cat nmor1 nmor2 nmor3 nmor4, statistics(mean) by(age_cat)
	esttab X2 using "$tables/Table8_SS.tex", cells("overestimation_cat nmor1 nmor2 nmor3 nmor4") plain nomtitle nonumber noobs append	
eststo X3 : estpost tabstat overestimation_cat nmor1 nmor2 nmor3 nmor4, statistics(mean) by(education)
	esttab X3 using "$tables/Table8_SS.tex", cells("overestimation_cat nmor1 nmor2 nmor3 nmor4") plain nomtitle nonumber noobs append	
eststo X4 : estpost tabstat overestimation_cat nmor1 nmor2 nmor3 nmor4, statistics(mean) by(marital_status)
	esttab X4 using "$tables/Table8_SS.tex", cells("overestimation_cat nmor1 nmor2 nmor3 nmor4") plain nomtitle nonumber noobs append	
eststo X5 : estpost tabstat overestimation_cat nmor1 nmor2 nmor3 nmor4, statistics(mean) by(level_income)
	esttab X5 using "$tables/Table8_SS.tex", cells("overestimation_cat nmor1 nmor2 nmor3 nmor4") plain nomtitle nonumber noobs append
}

*===========================================================================*
* 2. Regressions
*===========================================================================*

* Declaring sets of variables
global controls "Female Age d_employed d_retired i.marital_status Elementary HighSchool College satisfaction trust_gov trust_pres trust_just trust_pol trust_others"
global gun_own 			"arm3_std arm4_std arm5_std arm6_std"
global gun_own_no_std 	"arm3 arm4 arm5 arm6"
global gun_use 			"arm7 arm8 arm9"

* Style format for estout 
global styles "cells(b(star fmt(2)) se(par fmt(2))) starlevels(* .05 ** .01 *** .001) varlabels(_cons Constant) label mlabels(,none)"

* Declaring options for outreg2
*global outregopt excel bdec(2) sdec(2) slow(100) addtext(Controls, Yes, Country FE, Yes) keep(overestimation_std overplace_pc_std) nocons

	* Main variables: 
	* Overestimation 1 (std) = overestimation_std
	* Overplacement 1 (std)  = overplace_std_1

* Label vars 
label var overestimation_std "Overestimation$^{1}$ Index (standardized)"
label var overplace_pc_std_1 "Overplacement$^{1}$ (PCA, standardized) "

******************************************************************
* Table 1. Gun ownership 
******************************************************************
{
global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.8}{ \begin{tabular}{lcccc} \hline \hline\\[-2ex] &  & Security  & Citizens & Citizens  \\ Variable &  Police & guards & Home & Street\\ & [1] & [2] & [3] & [4]\\\hline \\[-2ex] \multicolumn{5}{l}{\bf Panel A: Overestimation} \\ ")

global estout_post postfoot(" \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Preferences for Gun Ownership and Carry.} \label{tab:Table1ed}\centering \vspace{0.35cm} \justifying \footnotesize Notes: Each column shows the regression coefficients and the robust standard errors in parentheses corresponding to OLS estimations of linear models using both standardized dependent and independent variables. Panels A and B present the coefficients of models that include only one measure of overconfidence, while panel C shows the coefficients of a model that includes both measures as independent variables. *** p$<$0.001, ** p$<$0.01, * p$<$0.05. Controls include: age, gender, marital status, education level, employment, trust (justice system, parliament, police, president and trust in others) and life satisfaction. All panels include controls and country fixed effects. Mean Dep. Var presents the mean of the dependent variable unstandardized. Survey questions used for the construction of the dependent and independent variables are available in Online Appendix \ref{questions}. \end{table}" ) 

global Panel_B prehead("\multicolumn{5}{l}{\bf Panel B: Overplacement} \\")
global Panel_C prehead("\multicolumn{5}{l}{\bf Panel C: Overestimation and overplacement} \\")

*----------------------------------------	
* Panel A: Overestimation
*---------------------------------------
foreach y of varlist $gun_own {
	local lab: var lab `y'
	eststo: reg `y' overestimation_std $controls i.PAIS, r
}
estout using "$tables/Table1.tex", $estout_pre_table $styles keep(overestimation_std) stats(N r2, labels( "Observations" "Adjusted-R-squared") fmt(0 3)) style(tex) collabels(none) prefoot(~\\) postfoot(\midrule) replace

eststo clear
*-----------------------------------------
* Panel B: Overplacement
*-----------------------------------------
foreach y of varlist $gun_own {
	local lab: var lab `y'
	eststo: reg `y' overplace_pc_std_1 $controls i.PAIS, r
}
estout using "$tables/Table1.tex", $Panel_B $styles keep(overplace_pc_std_1) stats(N r2, labels( "Observations" "Adjusted-R-squared") fmt(0 3)) style(tex) collabels(none) prefoot(~\\) postfoot(\midrule) append

eststo clear
*--------------------------------------------
* Panel C: Overestimation and overplacement
*--------------------------------------------

foreach y of varlist $gun_own_no_std  {
	local lab: var lab `y'_std
	eststo: reg `y'_std overestimation_std overplace_pc_std_1 $controls i.PAIS, r
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
		
	* We add the mean dependent variable for the un-standarized variable	
	qui sum `y' if e(sample)
	qui estadd scalar dep_var = round(`r(mean)', 0.01)
}
estout using "$tables/Table1.tex", $Panel_C $styles keep(overestimation_std overplace_pc_std_1) stats(N r2 controls FE_country dep_var, labels( "Observations" "Adjusted-R-squared" " \hline Controls" "Country FE" "\hline Mean Dep. Var (Not standarized)") fmt(0 3 0 0 2)) style(tex) collabels(none) prefoot(~\\) $estout_post append 
eststo clear
}
***************************************************************************
* Table 2. Gun ownership (Andres's version - Change in controls)
***************************************************************************
{
global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.55}{ \begin{tabular}{lcccccccc} \hline \hline\\[-2ex] & \multicolumn{3}{c}{In the street}  & \multicolumn{3}{c}{At home: Alone} & \multicolumn{2}{c}{At home: With family}  \\ \cmidrule(lr){2-4} \cmidrule(lr){5-7} \cmidrule(lr){8-9} \\[-2ex] Variable & Knife & Firearm & Always & Knife & Firearm & Always & Always & Equal weapon \\ & [1] & [2] & [3] & [4] & [5] & [6] & [7] & [8] \\ \hline \\[-2ex]\multicolumn{11}{l}{\bf Panel A: Overestimation} \\")

global estout_post postfoot("  \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Willingness to Offer Resistance in a Robbery}      \label{tab:Table2ed} \centering \vspace{0.35cm} \justifying       \footnotesize      Notes: Each column shows the regression coefficients and the robust standard errors in parentheses corresponding to a multinomial logistic model using standardized independent variables. The base category of the dependent variables is ``never offering resistance''. Panels A and B present the coefficients of models that include only one measure of overconfidence, while panel C shows the coefficients of a model that includes both measures as independent variables.     *** p$<$0.001, ** p$<$0.01, * p$<$0.05.      Controls include: age, gender, marital status, education level, employment, trust (justice system, parliament, police, president and others) and life satisfaction. All panels include controls and country fixed effects. Percentage of answers denote the total of participant that respond the question with that answer. Survey questions used for the construction of the dependent and independent variables are available in Online Appendix \ref{questions}.\end{table}" )

global Panel_B prehead("\multicolumn{11}{l}{\bf Panel B: Overplacement} \\")
global Panel_C prehead("\multicolumn{11}{l}{\bf Panel C: Overestimation and overplacement} \\")

*--------------------------
* Panel A: Overestimation
*--------------------------
local j = 1
foreach y of varlist $gun_use {
	local lab: var lab `y'
	mlogit `y' overestimation_std $controls i.PAIS, vce(robust) baseoutcome(1)
	estimate store store`j'
	local ++j
}
estout store1 store2 store3 using "$tables/Table2.tex", $estout_pre_table $styles eqlabels(,none) keep(overestimation_std) stats(N, labels( "Observations") fmt(0)) style(tex) collabels(none) unstack noomitted postfoot(\midrule) replace
eststo clear
*----------------------------
* Panel B: Overplacement
*----------------------------
foreach y of varlist $gun_use {
	local lab: var lab `y'
	eststo: mlogit `y' overplace_pc_std_1 $controls i.PAIS, vce(robust)
}
estout using "$tables/Table2.tex", $Panel_B $styles eqlabels(,none) keep(overplace_pc_std_1) stats(N, labels("Observations") fmt(0)) style(tex) collabels(none) unstack noomitted postfoot(\midrule) append
eststo clear
*--------------------------------------------
* Panel C: Overestimation and overplacement
*--------------------------------------------
foreach y of varlist $gun_use {
	local lab: var lab `y'
	eststo: mlogit `y' overestimation_std overplace_pc_std_1 $controls i.PAIS, vce(robust) baseoutcome(1)
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
		qui estadd local dep_var = ""
}
estout using "$tables/Table2.tex", $Panel_C $styles eqlabels(,none) keep(overestimation_std overplace_pc_std_1) stats(N controls FE_country dep_var, labels( "Observations" "\hline Controls" "Country FE" "\hline Perc. of answers") fmt(0 0 0)) style(tex) collabels(none) unstack noomitted $estout_post append 
eststo clear

	* Manually include the percentage of answers for each question
	qui tab arm7
	qui tab arm8
	qui tab arm9 
}	
******************************************************************
* Table A.9 Gun ownership - No controls
******************************************************************
{
global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.8}{ \begin{tabular}{lcccc} \hline \hline\\[-2ex] &  & Security  & Citizens & Citizens  \\ Variable &  Police & guards & Home & Street\\ & [1] & [2] & [3] & [4]\\\hline \\[-2ex]")

global estout_post postfoot(" \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Preferences for Gun Ownership and Carry, No controls} \label{tab:Table1ed}\centering \vspace{0.35cm} \justifying \footnotesize Notes: Each column shows the regression coefficients and the robust standard errors in parentheses corresponding to OLS estimations of linear models using both standardized dependent and independent variables. *** p$<$0.001, ** p$<$0.01, * p$<$0.05. No controls are included apart from country fixed effects. Survey questions used for the construction of the dependent and independent variables are available in Online Appendix \ref{questions}. \end{table}" ) 

foreach y of varlist $gun_own {
	local lab: var lab `y'
	eststo: reg `y' overestimation_std overplace_pc_std_1 i.PAIS, r
		qui estadd local controls = "No"
		qui estadd local FE_country = "Yes"
}
estout using "$tables/TableA9.tex", $estout_pre_table $styles keep(overestimation_std overplace_pc_std_1) stats(N r2 controls FE_country, labels( "Observations" "Adjusted-R-squared" " \midrule Controls" "Country FE") fmt(0 3 0 0)) style(tex) collabels(none) prefoot(\midrule) $estout_post replace
eststo clear	
}	
***************************************************************************
* Table A.10 Gun ownership - No controls
***************************************************************************
{
global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.7}{ \begin{tabular}{lcccccccc} \hline \hline\\[-2ex] & \multicolumn{3}{c}{In the street}  & \multicolumn{3}{c}{At home: Alone} & \multicolumn{2}{c}{At home: With family}  \\ \cmidrule(lr){2-4} \cmidrule(lr){5-7} \cmidrule(lr){8-9} \\[-2ex] Variable & Knife & Firearm & Always & Knife & Firearm & Always & Always & Equal weapon \\ & [1] & [2] & [3] & [4] & [5] & [6] & [7] & [8] \\ \hline \\[-2ex]")

global estout_post postfoot("  \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Willingness to Offer Resistance in a Robbery, No controls}      \label{tab:Table2ed} \centering \vspace{0.35cm} \justifying       \footnotesize      Notes: Each column shows the regression coefficients and the robust standard errors in parentheses corresponding to a multinomial logistic model using standardized independent variables. The base category of the dependent variables is never offering resistance   *** p$<$0.001, ** p$<$0.01, * p$<$0.05. No controls are included apart from country fixed effects. Survey questions used for the construction of the dependent and independent variables are available in Online Appendix \ref{questions}.\end{table}" )

foreach y of varlist $gun_use {
	local lab: var lab `y'
	eststo: mlogit `y' overestimation_std overplace_pc_std_1 i.PAIS, vce(robust) baseoutcome(1)
		qui estadd local controls = "No"
		qui estadd local FE_country = "Yes"
}
estout using "$tables/TableA10.tex", $estout_pre_table $styles eqlabels(,none) keep(overestimation_std overplace_pc_std_1) stats(N controls FE_country, labels( "Observations" "\midrule Controls" "Country FE") fmt(0 0 0)) style(tex) collabels(none) unstack noomitted $estout_post replace
eststo clear
}	
******************************************************************
* Table A.11. Gun ownership - Full controls 
******************************************************************
{
	global controls_2 "Female Age d_employed d_retired i.marital_status Elementary HighSchool College satisfaction trust_gov trust_pres trust_just trust_pol trust_others PenaltyCoins DetectionCoins PoliceCoins"

global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.8}{ \begin{tabular}{lcccc} \hline \hline\\[-2ex] &  & Security  & Citizens & Citizens  \\ Variable &  Police & guards & Home & Street\\ & [1] & [2] & [3] & [4]\\\hline \\[-2ex] \multicolumn{5}{l}{\bf Panel A: Overestimation} \\ ")

global estout_post postfoot(" \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Preferences for Gun Ownership and Carry. Full controls} \label{tab:Table1ed}\centering \vspace{0.35cm} \justifying \footnotesize Notes: Each column shows the regression coefficients and the robust standard errors in parentheses corresponding to OLS estimations of linear models using both standardized dependent and independent variables. Panels A and B present the coefficients of models that include only one measure of overconfidence, while panel C shows the coefficients of a model that includes both measures as independent variables. *** p$<$0.001, ** p$<$0.01, * p$<$0.05. Full controls include: age, gender, marital status, education level, employment, trust (justice system, parliament, police, president and trust in others), life satisfaction and punishment preferences. All panels include controls and country fixed effects. Mean Dep. Var presents the mean of the dependent variable unstandardized. Survey questions used for the construction of the dependent and independent variables are available in Online Appendix \ref{questions}. \end{table}" ) 

global Panel_B prehead("\multicolumn{5}{l}{\bf Panel B: Overplacement} \\")
global Panel_C prehead("\multicolumn{5}{l}{\bf Panel C: Overestimation and overplacement} \\")

*----------------------------------------	
* Panel A: Overestimation
*---------------------------------------
foreach y of varlist $gun_own {
	local lab: var lab `y'
	eststo: reg `y' overestimation_std $controls_2 i.PAIS, r
}
estout using "$tables/TableA11.tex", $estout_pre_table $styles keep(overestimation_std) stats(N r2, labels( "Observations" "Adjusted-R-squared") fmt(0 3)) style(tex) collabels(none) prefoot(~\\) postfoot(\midrule) replace

eststo clear
*-----------------------------------------
* Panel B: Overplacement
*-----------------------------------------
foreach y of varlist $gun_own {
	local lab: var lab `y'
	eststo: reg `y' overplace_pc_std_1 $controls_2 i.PAIS, r
}
estout using "$tables/TableA11.tex", $Panel_B $styles keep(overplace_pc_std_1) stats(N r2, labels( "Observations" "Adjusted-R-squared") fmt(0 3)) style(tex) collabels(none) prefoot(~\\) postfoot(\midrule) append

eststo clear
*--------------------------------------------
* Panel C: Overestimation and overplacement
*--------------------------------------------

foreach y of varlist $gun_own_no_std  {
	local lab: var lab `y'_std
	eststo: reg `y'_std overestimation_std overplace_pc_std_1 $controls_2 i.PAIS, r
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
}
estout using "$tables/TableA11.tex", $Panel_C $styles keep(overestimation_std overplace_pc_std_1) stats(N r2 controls FE_country, labels( "Observations" "Adjusted-R-squared" " \midrule Controls" "Country FE") fmt(0 3 0 0)) style(tex) collabels(none) prefoot(~\\) $estout_post append 
eststo clear
}
***************************************************************************
* Table A12. Gun ownership - Full controls
***************************************************************************
{

global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.65}{ \begin{tabular}{lcccccccc} \hline \hline\\[-2ex] & \multicolumn{3}{c}{In the street}  & \multicolumn{3}{c}{At home: Alone} & \multicolumn{2}{c}{At home: With family}  \\ \cmidrule(lr){2-4} \cmidrule(lr){5-7} \cmidrule(lr){8-9} \\[-2ex] Variable & Knife & Firearm & Always & Knife & Firearm & Always & Always & Equal weapon \\ & [1] & [2] & [3] & [4] & [5] & [6] & [7] & [8] \\ \hline \\[-2ex]\multicolumn{11}{l}{\bf Panel A: Overestimation} \\")

global estout_post postfoot("  \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Willingness to Offer Resistance in a Robbery. Full controls}      \label{tab:Table2ed} \centering \vspace{0.35cm} \justifying       \footnotesize      Notes: Each column shows the regression coefficients and the robust standard errors in parentheses corresponding to a multinomial logistic model using standardized independent variables. The base category of the dependent variables is ``never offering resistance''. Panels A and B present the coefficients of models that include only one measure of overconfidence, while panel C shows the coefficients of a model that includes both measures as independent variables.     *** p$<$0.001, ** p$<$0.01, * p$<$0.05. Full controls include: age, gender, marital status, education level, employment, trust (justice system, parliament, police, president and others), life satisfaction and punishment preferences. All panels include controls and country fixed effects. Percentage of answers denote the total of participant that respond the question with that answer. Survey questions used for the construction of the dependent and independent variables are available in Online Appendix \ref{questions}.\end{table}" )

global Panel_B prehead("\multicolumn{11}{l}{\bf Panel B: Overplacement} \\")
global Panel_C prehead("\multicolumn{11}{l}{\bf Panel C: Overestimation and overplacement} \\")

*--------------------------
* Panel A: Overestimation
*--------------------------
local j = 1
foreach y of varlist $gun_use {
	local lab: var lab `y'
	mlogit `y' overestimation_std $controls_2 i.PAIS, vce(robust) baseoutcome(1)
	estimate store store`j'
	local ++j
}
estout store1 store2 store3 using "$tables/TableA12.tex", $estout_pre_table $styles eqlabels(,none) keep(overestimation_std) stats(N, labels( "Observations") fmt(0)) style(tex) collabels(none) unstack noomitted postfoot(\midrule) replace
eststo clear
*----------------------------
* Panel B: Overplacement
*----------------------------
foreach y of varlist $gun_use {
	local lab: var lab `y'
	eststo: mlogit `y' overplace_pc_std_1 $controls_2 i.PAIS, vce(robust)
}
estout using "$tables/TableA12.tex", $Panel_B $styles eqlabels(,none) keep(overplace_pc_std_1) stats(N, labels("Observations") fmt(0)) style(tex) collabels(none) unstack noomitted postfoot(\midrule) append
eststo clear
*--------------------------------------------
* Panel C: Overestimation and overplacement
*--------------------------------------------
foreach y of varlist $gun_use {
	local lab: var lab `y'
	eststo: mlogit `y' overestimation_std overplace_pc_std_1 $controls_2 i.PAIS, vce(robust) baseoutcome(1)
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
}
estout using "$tables/TableA12.tex", $Panel_C $styles eqlabels(,none) keep(overestimation_std overplace_pc_std_1) stats(N controls FE_country, labels( "Observations" "\midrule Controls" "Country FE") fmt(0 0 0)) style(tex) collabels(none) unstack noomitted $estout_post append 
eststo clear
}
******************************************************************
* Table A.13 Gun ownership - Non standardized
******************************************************************
{
global gun_own_non arm3 arm4 arm5 arm6
* Label vars 
label var overestimation "Overestimation$^{1}$ Index"
label var overplace_pc_1 "Overplacement$^{1}$ (PCA)"

global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.8}{ \begin{tabular}{lcccc} \hline \hline\\[-2ex] &  & Security  & Citizens & Citizens  \\ Variable &  Police & guards & Home & Street\\ & [1] & [2] & [3] & [4]\\\hline \\[-2ex]")

global estout_post postfoot(" \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Preferences for Gun Ownership and Carry. Non-standardized variables} \label{tab:Table1ed}\centering \vspace{0.35cm} \justifying \footnotesize Notes: Each column shows the regression coefficients and the robust standard errors in parentheses corresponding to OLS estimations of linear models using the original non standardized dependent and independent variables. *** p$<$0.001, ** p$<$0.01, * p$<$0.05. Controls include: age, gender, marital status, education level, employment, trust (justice system, parliament, police, president and trust in others) and life satisfaction. All panels include controls and country fixed effects. Survey questions used for the construction of the dependent and independent variables are available in Online Appendix \ref{questions}. \end{table}" ) 

foreach y of varlist $gun_own_non {
	local lab: var lab `y'
	eststo: reg `y' overestimation overplace_pc_1 $controls i.PAIS, r
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
}
estout using "$tables/TableA13.tex", $estout_pre_table $styles keep(overestimation overplace_pc_1) stats(N r2 controls FE_country, labels( "Observations" "Adjusted-R-squared" " \midrule Controls" "Country FE") fmt(0 3 0 0)) style(tex) collabels(none) prefoot(\midrule) $estout_post replace
eststo clear	
}

***************************************************************************
* Table A.14 Gun ownership - Non standardized
***************************************************************************
{

global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.7}{ \begin{tabular}{lcccccccc} \hline \hline\\[-2ex] & \multicolumn{3}{c}{In the street}  & \multicolumn{3}{c}{At home: Alone} & \multicolumn{2}{c}{At home: With family}  \\ \cmidrule(lr){2-4} \cmidrule(lr){5-7} \cmidrule(lr){8-9} \\[-2ex] Variable & Knife & Firearm & Always & Knife & Firearm & Always & Always & Equal weapon \\ & [1] & [2] & [3] & [4] & [5] & [6] & [7] & [8] \\ \hline \\[-2ex]")

global estout_post postfoot("  \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Willingness to Offer Resistance in a Robbery, Non-standardized variables}      \label{tab:Table2ed} \centering \vspace{0.35cm} \justifying       \footnotesize      Notes: Each column shows the regression coefficients and the robust standard errors in parentheses corresponding to a multinomial logistic model using standardized independent variables. The base category of the dependent variables is never offering resistance   *** p$<$0.001, ** p$<$0.01, * p$<$0.05. Controls include: age, gender, marital status, education level, employment, trust (justice system, parliament, police, president and trust in others) and life satisfaction. Survey questions used for the construction of the dependent and independent variables are available in Online Appendix \ref{questions}.\end{table}" )

foreach y of varlist $gun_use {
	local lab: var lab `y'
	eststo: mlogit `y' overestimation overplace_pc_1 $controls i.PAIS, vce(robust) baseoutcome(1)
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
}
estout using "$tables/TableA14.tex", $estout_pre_table $styles eqlabels(,none) keep(overestimation overplace_pc_1) stats(N controls FE_country, labels( "Observations" "\midrule Controls" "Country FE") fmt(0 0 0)) style(tex) collabels(none) unstack noomitted $estout_post replace
eststo clear
}

******************************************************************
* Table A.15 Gun ownership - Binary Dependent Variable
******************************************************************
{
global gun_own_dumm d_narm3 d_narm4 d_narm5 d_narm6
global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.8}{ \begin{tabular}{lcccc} \hline \hline\\[-2ex] &  & Security  & Citizens & Citizens  \\ Variable &  Police & guards & Home & Street\\ & [1] & [2] & [3] & [4]\\\hline \\[-2ex]")

global estout_post postfoot(" \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Preferences for Gun Ownership and Carry. Binary Dependent Variable} \label{tab:Table1ed}\centering \vspace{0.35cm} \justifying \footnotesize Notes: Each column shows the regression coefficients and the robust standard errors in parentheses corresponding to OLS estimations of linear models using standardized independent variable and binary dependent variables. Agreement = 0 if agreement with statement is between 1 and 3. Agreement = 1 if agreement with statement is between 5 and 7. *** p$<$0.001, ** p$<$0.01, * p$<$0.05. Controls include: age, gender, marital status, education level, employment, trust (justice system, parliament, police, president and trust in others) and life satisfaction. All panels include controls and country fixed effects. Survey questions used for the construction of the dependent and independent variables are available in Online Appendix \ref{questions}. \end{table}" ) 

foreach y of varlist $gun_own_dumm {
	local lab: var lab `y'
	eststo: reg `y' overestimation_std overplace_pc_std_1 $controls i.PAIS, r
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
}
estout using "$tables/TableA15.tex", $estout_pre_table $styles keep(overestimation_std overplace_pc_std_1) stats(N r2 controls FE_country, labels( "Observations" "Adjusted-R-squared" " \midrule Controls" "Country FE") fmt(0 3 0 0)) style(tex) collabels(none) prefoot(\midrule) $estout_post replace
eststo clear	
}

************************************************************************
* Table A.16 Gun ownership - Binary Dependent Variable  (4 - 7 Agree)
************************************************************************
{
global gun_own_dumm_1 r1_d_narm3 r1_d_narm4 r1_d_narm5 r1_d_narm6
global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.8}{ \begin{tabular}{lcccc} \hline \hline\\[-2ex] &  & Security  & Citizens & Citizens  \\ Variable &  Police & guards & Home & Street\\ & [1] & [2] & [3] & [4]\\\hline \\[-2ex]")

global estout_post postfoot(" \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Preferences for Gun Ownership and Carry. Binary Dependent Variable (1 if Agree $\geq$ 4)} \label{tab:Table1ed}\centering \vspace{0.35cm} \justifying \footnotesize Notes: Each column shows the regression coefficients and the robust standard errors in parentheses corresponding to OLS estimations of linear models using standardized independent variable and binary dependent variables. Agreement = 0 if agreement with statement is between 1 and 3. Agreement = 1 if agreement with statement is between 4 and 7. *** p$<$0.001, ** p$<$0.01, * p$<$0.05. Controls include: age, gender, marital status, education level, employment, trust (justice system, parliament, police, president and trust in others) and life satisfaction. All panels include controls and country fixed effects. Survey questions used for the construction of the dependent and independent variables are available in Online Appendix \ref{questions}. \end{table}" ) 

foreach y of varlist $gun_own_dumm_1 {
	local lab: var lab `y'
	eststo: reg `y' overestimation_std overplace_pc_std_1 $controls i.PAIS, r
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
}
estout using "$tables/TableA16.tex", $estout_pre_table $styles keep(overestimation_std overplace_pc_std_1) stats(N r2 controls FE_country, labels( "Observations" "Adjusted-R-squared" " \midrule Controls" "Country FE") fmt(0 3 0 0)) style(tex) collabels(none) prefoot(\midrule) $estout_post replace
eststo clear	
}

************************************************************************
* Table A.17 Gun ownership - Binary Dependent Variable  (6 - 7 Agree)
************************************************************************
{
global gun_own_dumm_2 r2_d_narm3 r2_d_narm4 r2_d_narm5 r2_d_narm6
global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.8}{ \begin{tabular}{lcccc} \hline \hline\\[-2ex] &  & Security  & Citizens & Citizens  \\ Variable &  Police & guards & Home & Street\\ & [1] & [2] & [3] & [4]\\\hline \\[-2ex]")

global estout_post postfoot(" \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Preferences for Gun Ownership and Carry. Binary Dependent Variable (1 if Agree $\geq$ 6)} \label{tab:Table1ed}\centering \vspace{0.35cm} \justifying \footnotesize Notes: Each column shows the regression coefficients and the robust standard errors in parentheses corresponding to OLS estimations of linear models using standardized independent variable and binary dependent variables. Agreement = 0 if agreement with statement is between 1 and 5. Agreement = 1 if agreement with statement is between 6 and 7. *** p$<$0.001, ** p$<$0.01, * p$<$0.05. Controls include: age, gender, marital status, education level, employment, trust (justice system, parliament, police, president and trust in others) and life satisfaction. All panels include controls and country fixed effects. Survey questions used for the construction of the dependent and independent variables are available in Online Appendix \ref{questions}. \end{table}" ) 

foreach y of varlist $gun_own_dumm_2 {
	local lab: var lab `y'
	eststo: reg `y' overestimation_std overplace_pc_std_1 $controls i.PAIS, r
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
}
estout using "$tables/TableA17.tex", $estout_pre_table $styles keep(overestimation_std overplace_pc_std_1) stats(N r2 controls FE_country, labels( "Observations" "Adjusted-R-squared" " \midrule Controls" "Country FE") fmt(0 3 0 0)) style(tex) collabels(none) prefoot(\midrule) $estout_post replace
eststo clear	
}

***************************************************************************************
* Table A.18 Gun ownership - Binary Dependent Variable  (Sometimes and Always = 1)
***************************************************************************************
{
global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.8}{ \begin{tabular}{lccc} \hline \hline\\[-2ex] Variable &  In the street  & At home: Alone & At home: With family  \\ & [1] & [2] & [3] \\\hline \\[-2ex]")

global estout_post postfoot(" \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Willingness to Offer Resistance in a Robbery, Binary Dependent Variables (Sometimes = 1)} \label{tab:Table1ed}\centering \vspace{0.35cm} \justifying        \footnotesize Notes: Each column shows the regression coefficients and the robust standard errors in parentheses corresponding to OLS estimations of linear models using standardized independent variables and binary dependent variables. Dependent variables are defined as 1 for Always and Sometimes (Both with knife or Firearm) and 0 for Never. *** p$<$0.001, ** p$<$0.01, * p$<$0.05. Controls include: age, gender, marital status, education level, employment, trust (justice system, parliament, police and president) and life satisfaction. Survey questions used for the construction of the dependent and independent variables are available in Appendix \ref{questions}.\end{table}" )

foreach y of varlist d_narm7 d_narm8 d_narm9 {
	local lab: var lab `y'
	eststo: reg `y' overestimation_std overplace_pc_std_1 $controls i.PAIS, r
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
}
estout using "$tables/TableA18.tex", $estout_pre_table $styles keep(overestimation_std overplace_pc_std_1) stats(N r2 controls FE_country, labels( "Observations" "Adjusted-R-squared" " \midrule Controls" "Country FE") fmt(0 3 0 0)) style(tex) collabels(none) prefoot(\midrule) $estout_post replace 
eststo clear
}

****************************************************************************************************
* Table A.19 Gun ownership - Binary Dependent Variable  (Always = 1)(Sometimes and Never = 0)
****************************************************************************************************
{
global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.8}{ \begin{tabular}{lccc} \hline \hline\\[-2ex] Variable &  In the street  & At home: Alone & At home: With family  \\ & [1] & [2] & [3] \\\hline \\[-2ex]")

global estout_post postfoot(" \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Willingness to Offer Resistance in a Robbery, Binary Dependent Variables (Sometimes = 0)} \label{tab:Table1ed}\centering  \vspace{0.35cm} \justifying      \footnotesize Notes: Each column shows the regression coefficients and the robust standard errors in parentheses corresponding to OLS estimations of linear models using standardized independent variables and binary dependent variables.  Dependent variables are defined as 1 for Always and 0 for Never and Sometimes (Both with knife or Firearm). *** p$<$0.001, ** p$<$0.01, * p$<$0.05. Controls include: age, gender, marital status, education level, employment, trust (justice system, parliament, police and president) and life satisfaction. Survey questions used for the construction of the dependent and independent variables are available in Appendix \ref{questions}.\end{table}" )

foreach y of varlist r1_d_narm7 r1_d_narm8 r1_d_narm9 {
	local lab: var lab `y'
	eststo: reg `y' overestimation_std overplace_pc_std_1 $controls i.PAIS, r
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
}
estout using "$tables/TableA19.tex", $estout_pre_table $styles keep(overestimation_std overplace_pc_std_1) stats(N r2 controls FE_country, labels( "Observations" "Adjusted-R-squared" " \midrule Controls" "Country FE") fmt(0 3 0)) style(tex) collabels(none) prefoot(\midrule) $estout_post replace 
eststo clear
}

***************************************************************************
* Table A20. Gun ownership (Modify Knife and Gun in same category)
***************************************************************************
{
global gun_use_2 narm7 narm8 narm9 
	
global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.7}{ \begin{tabular}{lcccccc} \hline \hline\\[-2ex] & \multicolumn{2}{c}{In the street}  & \multicolumn{2}{c}{At home: Alone} & \multicolumn{2}{c}{At home: With family}  \\ \cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(lr){6-7} \\[-2ex] Variable & Sometimes & Always & Sometimes & Always & Sometimes & Always \\ & [1] & [2] & [3] & [4] & [5] & [6] \\ \hline \\[-2ex]\multicolumn{7}{l}{\bf Panel A: Overestimation} \\")

global estout_post postfoot("  \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Willingness to Offer Resistance in a Robbery - Knife and Firearm in same category}      \label{tab:Table2ed} \centering \vspace{0.35cm} \justifying       \footnotesize      Notes: Each column shows the regression coefficients and the robust standard errors in parentheses corresponding to a multinomial logistic model using standardized independent variables. The base category of the dependent variables is never offering resistance. Knife and Guns are merged in the same category. Panels A and B present the coefficients of models that include only one measure of overconfidence, while panel C shows the coefficients of a model that includes both measures as independent variables.     *** p$<$0.001, ** p$<$0.01, * p$<$0.05.      Controls include: age, gender, marital status, education level, employment, trust (justice system, parliament, police, president and trust in others) and life satisfaction. All panels include controls and country fixed effects. Percentage of answers denote the total of participant that respond the question with that answer. Survey questions used for the construction of the dependent and independent variables are available in Online Appendix \ref{questions}.\end{table}" )

global Panel_B prehead("\multicolumn{7}{l}{\bf Panel B: Overplacement} \\")
global Panel_C prehead("\multicolumn{7}{l}{\bf Panel C: Overestimation and overplacement} \\")

*--------------------------
* Panel A: Overestimation
*--------------------------
local j = 1
foreach y of varlist $gun_use_2 {
	local lab: var lab `y'
	mlogit `y' overestimation_std $controls i.PAIS, vce(robust) baseoutcome(0)
	estimate store store`j'
	local ++j
}
estout store1 store2 store3 using "$tables/TableA20.tex", $estout_pre_table $styles eqlabels(,none) keep(overestimation_std) stats(N, labels( "Observations") fmt(0)) style(tex) collabels(none) unstack noomitted postfoot(\midrule) replace
eststo clear
*----------------------------
* Panel B: Overplacement
*----------------------------
foreach y of varlist $gun_use_2 {
	local lab: var lab `y'
	eststo: mlogit `y' overplace_pc_std_1 $controls i.PAIS, vce(robust) baseoutcome(0)
}
estout using "$tables/TableA20.tex", $Panel_B $styles eqlabels(,none) keep(overplace_pc_std_1) stats(N, labels("Observations") fmt(0)) style(tex) collabels(none) unstack noomitted postfoot(\midrule) append
eststo clear
*--------------------------------------------
* Panel C: Overestimation and overplacement
*--------------------------------------------
foreach y of varlist $gun_use_2 {
	local lab: var lab `y'
	eststo: mlogit `y' overestimation_std overplace_pc_std_1 $controls i.PAIS, vce(robust) baseoutcome(0)
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
		qui estadd local dep_var = ""
}
estout using "$tables/TableA20.tex", $Panel_C $styles eqlabels(,none) keep(overestimation_std overplace_pc_std_1) stats(N controls FE_country, labels( "Observations" "\hline Controls" "Country FE") fmt(0 0 0)) style(tex) collabels(none) unstack noomitted $estout_post append 
eststo clear
}	


******************************************************************
* Table A.21 Gun ownership - Change in Overestimation 2 
******************************************************************
{
	* Main variables: 
	* Overestimation 2 (std) = overestimation_2_std

* Label vars 
label var overestimation_2_std "Overestimation$^{2}$ Index (standardized)"

global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.8}{ \begin{tabular}{lcccc} \hline \hline\\[-2ex] &  & Security  & Citizens & Citizens  \\ Variable &  Police & guards & Home & Street\\ & [1] & [2] & [3] & [4]\\\hline \\[-2ex] \multicolumn{5}{l}{\bf Panel A: Overestimation} \\ ")

global estout_post postfoot(" \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Preferences for Gun Ownership and Carry.} \label{tab:Table1ed}\centering \vspace{0.35cm} \justifying \footnotesize Notes: Each column shows the regression coefficients and the robust standard errors in parentheses corresponding to OLS estimations of linear models using both standardized dependent and independent variables. The overestimation alternative index (2) is defined using the question-by-question method for estimation of right answers instead of the final question on the number of expected correct answers. *** p$<$0.001, ** p$<$0.01, * p$<$0.05. Controls include: age, gender, marital status, education level, employment, trust (justice system, parliament, police, president and trust in others) and life satisfaction. All panels include controls and country fixed effects. Survey questions used for the construction of the dependent and independent variables are available in Online Appendix \ref{questions}. \end{table}" ) 

global Panel_B prehead("\multicolumn{5}{l}{\bf Panel B: Overestimation and overplacement} \\")

*----------------------------------------	
* Panel A: Overestimation
*---------------------------------------
foreach y of varlist $gun_own {
	local lab: var lab `y'
	eststo: reg `y' overestimation_2_std $controls i.PAIS, r
}
estout using "$tables/TableA21.tex", $estout_pre_table $styles keep(overestimation_2_std) stats(N r2, labels( "Observations" "Adjusted-R-squared") fmt(0 3)) style(tex) collabels(none) prefoot(~\\) postfoot(\midrule) replace

eststo clear
*--------------------------------------------
* Panel B: Overestimation and overplacement
*--------------------------------------------

foreach y of varlist $gun_own_no_std  {
	local lab: var lab `y'_std
	eststo: reg `y'_std overestimation_2_std overplace_pc_std_1 $controls i.PAIS, r
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
}
estout using "$tables/TableA21.tex", $Panel_B $styles keep(overestimation_2_std overplace_pc_std_1) stats(N r2 controls FE_country, labels( "Observations" "Adjusted-R-squared" " \hline Controls" "Country FE") fmt(0 3 0 0)) style(tex) collabels(none) prefoot(~\\) $estout_post append 
eststo clear
}

******************************************************************
* Table A.22 Gun ownership - Change in Overplacement 2 
******************************************************************
{
	* Main variables: 
	* Overplacement 2 (std)  = overplace_pc_std_2

* Label vars 
label var overplace_pc_std_2 "Overplacement$^{2}$ (PCA, standardized) "

global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.8}{ \begin{tabular}{lcccc} \hline \hline\\[-2ex] &  & Security  & Citizens & Citizens  \\ Variable &  Police & guards & Home & Street\\ & [1] & [2] & [3] & [4]\\\hline \\[-2ex] \multicolumn{5}{l}{\bf Panel A: Overplacement} \\ ")

global estout_post postfoot(" \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Preferences for Gun Ownership and Carry.} \label{tab:Table1ed}\centering \vspace{0.35cm} \justifying \footnotesize Notes: Each column shows the regression coefficients and the robust standard errors in parentheses corresponding to OLS estimations of linear models using both standardized dependent and independent variables. The overplacement alternative index (2) excludes the weapons question in the PCA. *** p$<$0.001, ** p$<$0.01, * p$<$0.05. Controls include: age, gender, marital status, education level, employment, trust (justice system, parliament, police, president and trust in others) and life satisfaction. All panels include controls and country fixed effects. Survey questions used for the construction of the dependent and independent variables are available in Online Appendix \ref{questions}. \end{table}" ) 

global Panel_B prehead("\multicolumn{5}{l}{\bf Panel B: Overestimation and overplacement} \\")

*----------------------------------------	
* Panel A: Overplacement
*---------------------------------------
foreach y of varlist $gun_own {
	local lab: var lab `y'
	eststo: reg `y' overplace_pc_std_2 $controls i.PAIS, r
}
estout using "$tables/TableA22.tex", $estout_pre_table $styles keep(overplace_pc_std_2) stats(N r2, labels( "Observations" "Adjusted-R-squared") fmt(0 3)) style(tex) collabels(none) prefoot(~\\) postfoot(\midrule) replace

eststo clear
*--------------------------------------------
* Panel C: Overestimation and overplacement
*--------------------------------------------

foreach y of varlist $gun_own_no_std  {
	local lab: var lab `y'_std
	eststo: reg `y'_std overestimation_std overplace_pc_std_2 $controls i.PAIS, r
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
}
estout using "$tables/TableA22.tex", $Panel_B $styles keep(overestimation_std overplace_pc_std_2) stats(N r2 controls FE_country, labels( "Observations" "Adjusted-R-squared" " \hline Controls" "Country FE") fmt(0 3 0 0)) style(tex) collabels(none) prefoot(~\\) $estout_post append 
eststo clear
}

***********************************************************************
* Table A.23 Gun ownership - Change in Overstimation and Overplacement
***********************************************************************
{
global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.8}{ \begin{tabular}{lcccc} \hline \hline\\[-2ex] &  & Security  & Citizens & Citizens  \\ Variable &  Police & guards & Home & Street\\ & [1] & [2] & [3] & [4]\\\hline \\[-2ex]")

global estout_post postfoot(" \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Preferences for Gun Ownership and Carry} \label{tab:Table1ed}\centering \vspace{0.35cm} \justifying \footnotesize Notes: Each column shows the regression coefficients and the robust standard errors in parentheses corresponding to OLS estimations of linear models using both standardized dependent and independent variables. The overestimation alternative index (2) is defined using the question-by-question method for estimation of right answers instead of the final question on the number of expected correct answers. The overplacement alternative index (2) excludes the weapons question in the PCA. *** p$<$0.001, ** p$<$0.01, * p$<$0.05. Controls include: age, gender, marital status, education level, employment, trust (justice system, parliament, police, president and trust in others) and life satisfaction. All panels include controls and country fixed effects. Survey questions used for the construction of the dependent and independent variables are available in Online Appendix \ref{questions}. \end{table}" ) 

foreach y of varlist $gun_own {
	local lab: var lab `y'
	eststo: reg `y' overestimation_2_std overplace_pc_std_2 $controls i.PAIS, r
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
}
estout using "$tables/TableA23.tex", $estout_pre_table $styles keep(overestimation_2_std overplace_pc_std_2) stats(N r2 controls FE_country, labels( "Observations" "Adjusted-R-squared" " \midrule Controls" "Country FE") fmt(0 3 0 0)) style(tex) collabels(none) prefoot(\midrule) $estout_post replace
eststo clear	
}	

****************************************************************************
* Table A.24 Gun ownership - Change in Overestimation and overplacement
****************************************************************************
{
global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.55}{ \begin{tabular}{lcccccccc} \hline \hline\\[-2ex] & \multicolumn{3}{c}{In the street}  & \multicolumn{3}{c}{At home: Alone} & \multicolumn{2}{c}{At home: With family}  \\ \cmidrule(lr){2-4} \cmidrule(lr){5-7} \cmidrule(lr){8-9} \\[-2ex] Variable & Knife & Firearm & Always & Knife & Firearm & Always & Always & Equal weapon \\ & [1] & [2] & [3] & [4] & [5] & [6] & [7] & [8] \\ \hline \\[-2ex]\multicolumn{11}{l}{\bf Panel A: Overestimation} \\")

global estout_post postfoot("  \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Willingness to Offer Resistance in a Robbery}      \label{tab:Table2ed} \centering \vspace{0.35cm} \justifying       \footnotesize      Notes: Each column shows the regression coefficients and the robust standard errors in parentheses corresponding to a multinomial logistic model using standardized independent variables. The base category of the dependent variables is ``never offering resistance''. Panels A and B present the coefficients of models that include only one measure of overconfidence, while panel C shows the coefficients of a model that includes both measures as independent variables. The overestimation alternative index (2) is defined using the question-by-question method for estimation of right answers instead of the final question on the number of expected correct answers. The overplacement alternative index (2) excludes the weapons question in the PCA.    *** p$<$0.001, ** p$<$0.01, * p$<$0.05.      Controls include: age, gender, marital status, education level, employment, trust (justice system, parliament, police, president and others) and life satisfaction. All panels include controls and country fixed effects. Percentage of answers denote the total of participant that respond the question with that answer. Survey questions used for the construction of the dependent and independent variables are available in Online Appendix \ref{questions}.\end{table}" )

global Panel_B prehead("\multicolumn{11}{l}{\bf Panel B: Overplacement} \\")
global Panel_C prehead("\multicolumn{11}{l}{\bf Panel C: Overestimation and overplacement} \\")
global Panel_D prehead("\multicolumn{11}{l}{\bf Panel D: Overestimation and overplacement} \\")
global Panel_E prehead("\multicolumn{11}{l}{\bf Panel E: Overestimation and overplacement} \\")

*--------------------------
* Panel A: Overestimation
*--------------------------
local j = 1
foreach y of varlist $gun_use {
	local lab: var lab `y'
	mlogit `y' overestimation_2_std $controls i.PAIS, vce(robust) baseoutcome(1)
	estimate store store`j'
	local ++j
}
estout store1 store2 store3 using "$tables/TableA24.tex", $estout_pre_table $styles eqlabels(,none) keep(overestimation_2_std) stats(N, labels( "Observations") fmt(0)) style(tex) collabels(none) unstack noomitted postfoot(\midrule) replace
eststo clear
*----------------------------
* Panel B: Overplacement
*----------------------------
foreach y of varlist $gun_use {
	local lab: var lab `y'
	eststo: mlogit `y' overplace_pc_std_2 $controls i.PAIS, vce(robust)
}
estout using "$tables/TableA24.tex", $Panel_B $styles eqlabels(,none) keep(overplace_pc_std_2) stats(N, labels("Observations") fmt(0)) style(tex) collabels(none) unstack noomitted postfoot(\midrule) append
eststo clear
*----------------------------
* Panel C: Overplacement and overplacement
*----------------------------
foreach y of varlist $gun_use {
	local lab: var lab `y'
	eststo: mlogit `y' overestimation_std overplace_pc_std_2 $controls i.PAIS, vce(robust)
}
estout using "$tables/TableA24.tex", $Panel_C $styles eqlabels(,none) keep(overestimation_std overplace_pc_std_2) stats(N, labels("Observations") fmt(0)) style(tex) collabels(none) unstack noomitted postfoot(\midrule) append
eststo clear
*----------------------------
* Panel D: Overplacement and overplacement
*----------------------------
foreach y of varlist $gun_use {
	local lab: var lab `y'
	eststo: mlogit `y' overestimation_2_std overplace_pc_std_1 $controls i.PAIS, vce(robust)
}
estout using "$tables/TableA24.tex", $Panel_D $styles eqlabels(,none) keep(overestimation_2_std overplace_pc_std_1) stats(N, labels("Observations") fmt(0)) style(tex) collabels(none) unstack noomitted postfoot(\midrule) append
eststo clear
*--------------------------------------------
* Panel E: Overestimation and overplacement
*--------------------------------------------
foreach y of varlist $gun_use {
	local lab: var lab `y'
	eststo: mlogit `y' overestimation_2_std overplace_pc_std_2 $controls i.PAIS, vce(robust) baseoutcome(1)
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
}
estout using "$tables/TableA24.tex", $Panel_E $styles eqlabels(,none) keep(overestimation_2_std overplace_pc_std_2) stats(N controls FE_country, labels( "Observations" "\hline Controls" "Country FE") fmt(0 0 0)) style(tex) collabels(none) unstack noomitted $estout_post append 
eststo clear
}

******************************************************************
* Table A.25 Gun ownership - Overplacement by components
******************************************************************
{
	
	label var d_nmor1 "Overplacement: Responsibility"
	label var d_nmor2 "Overplacement: Decisions"
	label var d_nmor3 "Overplacement: Morality"
	label var d_nmor4 "Overplacement: Weapons"
	
global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.8}{ \begin{tabular}{lcccc} \hline \hline\\[-2ex] &  & Security  & Citizens & Citizens  \\ Variable &  Police & guards & Home & Street\\ & [1] & [2] & [3] & [4]\\\hline \\[-2ex] \multicolumn{5}{l}{\bf Panel A: Including weapons component} \\ ")

global estout_post postfoot(" \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Preferences for Gun Ownership and Carry.} \label{tab:Table1ed}\centering \vspace{0.35cm} \justifying \footnotesize Notes: Each column shows the regression coefficients and the robust standard errors in parentheses corresponding to OLS estimations of linear models using standardized dependent variables, the standardized overstimation index and binary indicators for each component of overplacement, which take the value 1 when the respondent express being above the average citizen in that dimension. *** p$<$0.001, ** p$<$0.01, * p$<$0.05. Controls include: age, gender, marital status, education level, employment, trust (justice system, parliament, police, president and trust in others) and life satisfaction. All panels include controls and country fixed effects. Survey questions used for the construction of the dependent and independent variables are available in Online Appendix \ref{questions}. \end{table}" ) 

global Panel_B prehead("\multicolumn{5}{l}{\bf Panel B: Excluding weapons component} \\")

*----------------------------------------	
* Panel A: Including weapons component
*---------------------------------------
foreach y of varlist $gun_own {
	local lab: var lab `y'
	eststo: reg `y' overestimation_std d_nmor1 d_nmor2 d_nmor3 d_nmor4 $controls i.PAIS, r
}
estout using "$tables/TableA25.tex", $estout_pre_table $styles keep(overestimation_std d_nmor1 d_nmor2 d_nmor3 d_nmor4) stats(N r2, labels( "Observations" "Adjusted-R-squared") fmt(0 3)) style(tex) collabels(none) prefoot(~\\) postfoot(\midrule) replace

eststo clear
*--------------------------------------------
* Panel B: Excluding weapons component
*--------------------------------------------

foreach y of varlist $gun_own  {
	local lab: var lab `y'
	eststo: reg `y' overestimation_std d_nmor1 d_nmor2 d_nmor3 $controls i.PAIS, r
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
}
estout using "$tables/TableA25.tex", $Panel_B $styles keep(overestimation_std d_nmor1 d_nmor2 d_nmor3) stats(N r2 controls FE_country, labels( "Observations" "Adjusted-R-squared" " \hline Controls" "Country FE") fmt(0 3 0 0)) style(tex) collabels(none) prefoot(~\\) $estout_post append 
eststo clear	
}

*******************************************************************
* Table A.26 Gun ownership - Overplacement by components
*******************************************************************
{
global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.65}{ \begin{tabular}{lcccccccc} \hline \hline\\[-2ex] & \multicolumn{3}{c}{In the street}  & \multicolumn{3}{c}{At home: Alone} & \multicolumn{2}{c}{At home: With family}  \\ \cmidrule(lr){2-4} \cmidrule(lr){5-7} \cmidrule(lr){8-9} \\[-2ex] Variable & Knife & Firearm & Always & Knife & Firearm & Always & Always & Equal weapon \\ & [1] & [2] & [3] & [4] & [5] & [6] & [7] & [8] \\ \hline \\[-2ex]\multicolumn{11}{l}{\bf Panel A: Including weapons component} \\")

global estout_post postfoot("  \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Willingness to Offer Resistance in a Robbery}      \label{tab:Table2ed} \centering \vspace{0.35cm} \justifying       \footnotesize      Notes: Each column shows the regression coefficients and the robust standard errors in parentheses corresponding to a multinomial logistic model using the standardized overestimation index and binary indicators for each component of overplacement, which take the value 1 when the respondent express being above the average citizen in that dimension. he base category of the dependent variables is never offering resistance.    *** p$<$0.001, ** p$<$0.01, * p$<$0.05.      Controls include: age, gender, marital status, education level, employment, trust (justice system, parliament, police, president and trust in others) and life satisfaction. All panels include controls and country fixed effects. Percentage of answers denote the total of participant that respond the question with that answer. Survey questions used for the construction of the dependent and independent variables are available in Online Appendix \ref{questions}.\end{table}" )

global Panel_B prehead("\multicolumn{11}{l}{\bf Panel B: Excluding weapons component} \\")

*---------------------------------------
* Panel A: Including weapons component
*---------------------------------------
local j = 1
foreach y of varlist $gun_use {
	local lab: var lab `y'
	mlogit `y' overestimation_std d_nmor1 d_nmor2 d_nmor3 d_nmor4 $controls i.PAIS, vce(robust) baseoutcome(1)
	estimate store store`j'
	local ++j
}
estout store1 store2 store3 using "$tables/TableA26.tex", $estout_pre_table $styles eqlabels(,none) keep(overestimation_std d_nmor1 d_nmor2 d_nmor3 d_nmor4) stats(N, labels( "Observations") fmt(0)) style(tex) collabels(none) unstack noomitted postfoot(\midrule) replace
eststo clear

*--------------------------------------------
* Panel B: Excluding weapons component
*--------------------------------------------
foreach y of varlist $gun_use {
	local lab: var lab `y'
	eststo: mlogit `y' overestimation_std d_nmor1 d_nmor2 d_nmor3 $controls i.PAIS, vce(robust) baseoutcome(1)
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
}
estout using "$tables/TableA26.tex", $Panel_B $styles eqlabels(,none) keep(overestimation_std d_nmor1 d_nmor2 d_nmor3) stats(N controls FE_country, labels( "Observations" "\hline Controls" "Country FE") fmt(0 0 0)) style(tex) collabels(none) unstack noomitted $estout_post append 
eststo clear
}

******************************************************************
* Table A.27 Gun ownership - Overplacement component by component 
******************************************************************
{
	
global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.8}{ \begin{tabular}{lcccc} \hline \hline\\[-2ex] &  & Security  & Citizens & Citizens  \\ Variable &  Police & guards & Home & Street\\ & [1] & [2] & [3] & [4]\\\hline \\[-2ex] \multicolumn{5}{l}{\bf Panel A: Responsibility} \\ ")

global estout_post postfoot(" \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Preferences for Gun Ownership and Carry.} \label{tab:Table1ed}\centering \vspace{0.35cm} \justifying \footnotesize Notes: Each column shows the regression coefficients and the robust standard errors in parentheses corresponding to OLS estimations of linear models using standardized dependent variables, the standardized overstimation index and binary indicators for each component of overplacement, which take the value 1 when the respondent express being above the average citizen in that dimension. *** p$<$0.001, ** p$<$0.01, * p$<$0.05. Controls include: age, gender, marital status, education level, employment, trust (justice system, parliament, police, president and trust in others) and life satisfaction. All panels include controls and country fixed effects. Survey questions used for the construction of the dependent and independent variables are available in Online Appendix \ref{questions}. \end{table}" ) 

global Panel_B prehead("\multicolumn{5}{l}{\bf Panel B: Ability to make decisions} \\")
global Panel_C prehead("\multicolumn{5}{l}{\bf Panel C: Morality} \\")
global Panel_D prehead("\multicolumn{5}{l}{\bf Panel D: Weapons} \\")

*----------------------------------------	
* Panel A: Responsibility
*---------------------------------------
foreach y of varlist $gun_own {
	local lab: var lab `y'
	eststo: reg `y' overestimation_std d_nmor1 $controls i.PAIS, r
}
estout using "$tables/TableA27.tex", $estout_pre_table $styles keep(overestimation_std d_nmor1) stats(N r2, labels( "Observations" "Adjusted-R-squared") fmt(0 3)) style(tex) collabels(none) prefoot(~\\) postfoot(\midrule) replace
eststo clear
*----------------------------------------	
* Panel B: Decisions
*---------------------------------------
foreach y of varlist $gun_own {
	local lab: var lab `y'
	eststo: reg `y' overestimation_std d_nmor2 $controls i.PAIS, r
}
estout using "$tables/TableA27.tex", $Panel_B $styles keep(overestimation_std d_nmor2) stats(N r2, labels( "Observations" "Adjusted-R-squared") fmt(0 3)) style(tex) collabels(none) prefoot(~\\) postfoot(\midrule) append 
eststo clear
*----------------------------------------	
* Panel C: Morality
*---------------------------------------
foreach y of varlist $gun_own {
	local lab: var lab `y'
	eststo: reg `y' overestimation_std d_nmor3 $controls i.PAIS, r
}
estout using "$tables/TableA27.tex", $Panel_C $styles keep(overestimation_std d_nmor3) stats(N r2, labels( "Observations" "Adjusted-R-squared") fmt(0 3)) style(tex) collabels(none) prefoot(~\\) postfoot(\midrule) append 
eststo clear
*--------------------------------------------
* Panel D: Weapons
*--------------------------------------------
foreach y of varlist $gun_own  {
	local lab: var lab `y'
	eststo: reg `y' overestimation_std d_nmor4 $controls i.PAIS, r
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
}
estout using "$tables/TableA27.tex", $Panel_D $styles keep(overestimation_std d_nmor4) stats(N r2 controls FE_country, labels( "Observations" "Adjusted-R-squared" " \hline Controls" "Country FE") fmt(0 3 0 0)) style(tex) collabels(none) prefoot(~\\) $estout_post append 
eststo clear	
}

******************************************************************
* Table A.28 Gun ownership - Overplacement component by component 
******************************************************************
{
	
global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.65}{ \begin{tabular}{lcccccccc} \hline \hline\\[-2ex] & \multicolumn{3}{c}{In the street}  & \multicolumn{3}{c}{At home: Alone} & \multicolumn{2}{c}{At home: With family}  \\ \cmidrule(lr){2-4} \cmidrule(lr){5-7} \cmidrule(lr){8-9} \\[-2ex] Variable & Knife & Firearm & Always & Knife & Firearm & Always & Always & Equal weapon \\ & [1] & [2] & [3] & [4] & [5] & [6] & [7] & [8] \\ \hline \\[-2ex]\multicolumn{11}{l}{\bf Panel A: Responsibility} \\")

global estout_post postfoot("  \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Willingness to Offer Resistance in a Robbery}      \label{tab:Table2ed} \centering \vspace{0.35cm} \justifying       \footnotesize      Notes: Each column shows the regression coefficients and the robust standard errors in parentheses corresponding to a multinomial logistic model using the standardized overestimation index and binary indicators for each component of overplacement, which take the value 1 when the respondent express being above the average citizen in that dimension. he base category of the dependent variables is never offering resistance.    *** p$<$0.001, ** p$<$0.01, * p$<$0.05.      Controls include: age, gender, marital status, education level, employment, trust (justice system, parliament, police, president and trust in others) and life satisfaction. All panels include controls and country fixed effects. Percentage of answers denote the total of participant that respond the question with that answer. Survey questions used for the construction of the dependent and independent variables are available in Online Appendix \ref{questions}.\end{table}" )


global Panel_B prehead("\multicolumn{11}{l}{\bf Panel B: Ability to make decisions} \\")
global Panel_C prehead("\multicolumn{11}{l}{\bf Panel C: Morality} \\")
global Panel_D prehead("\multicolumn{11}{l}{\bf Panel D: Weapons} \\")

*----------------------------------------	
* Panel A: Responsibility
*---------------------------------------
local j = 1
foreach y of varlist $gun_use {
	local lab: var lab `y'
	mlogit `y' overestimation_std d_nmor1 $controls i.PAIS, vce(robust) baseoutcome(1)
	estimate store store`j'
	local ++j
}
estout store1 store2 store3 using "$tables/TableA28.tex", $estout_pre_table $styles eqlabels(,none) keep(overestimation_std d_nmor1) stats(N, labels( "Observations") fmt(0)) style(tex) collabels(none) unstack noomitted postfoot(\midrule) replace
eststo clear
*----------------------------------------	
* Panel B: Decisions
*---------------------------------------
local j = 1
foreach y of varlist $gun_use {
	local lab: var lab `y'
	mlogit `y' overestimation_std d_nmor2 $controls i.PAIS, vce(robust) baseoutcome(1)
	estimate store store`j'
	local ++j
}
estout store1 store2 store3 using "$tables/TableA28.tex", $Panel_B $styles eqlabels(,none) keep(overestimation_std d_nmor2) stats(N, labels( "Observations") fmt(0)) style(tex) collabels(none) unstack noomitted postfoot(\midrule) append
eststo clear
*----------------------------------------	
* Panel C: Morality
*---------------------------------------
local j = 1
foreach y of varlist $gun_use {
	local lab: var lab `y'
	mlogit `y' overestimation_std d_nmor3 $controls i.PAIS, vce(robust) baseoutcome(1)
	estimate store store`j'
	local ++j
}
estout store1 store2 store3 using "$tables/TableA28.tex", $Panel_C $styles eqlabels(,none) keep(overestimation_std d_nmor3) stats(N, labels( "Observations") fmt(0)) style(tex) collabels(none) unstack noomitted postfoot(\midrule) append
eststo clear
*--------------------------------------------
* Panel D: Weapons
*--------------------------------------------
foreach y of varlist $gun_use {
	local lab: var lab `y'
	eststo: mlogit `y' overestimation_std d_nmor4 $controls i.PAIS, vce(robust) baseoutcome(1)
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
}
estout using "$tables/TableA28.tex", $Panel_D $styles eqlabels(,none) keep(overestimation_std d_nmor4) stats(N controls FE_country, labels( "Observations" "\hline Controls" "Country FE") fmt(0 0 0)) style(tex) collabels(none) unstack noomitted $estout_post append 
eststo clear
}

***********************************************************************
* Table A.29 Gun ownership - Binary Overestimate 
***********************************************************************
{
	
	label var overestim_dummy "Overestimation (binary)"
	
global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.8}{ \begin{tabular}{lcccc} \hline \hline\\[-2ex] &  & Security  & Citizens & Citizens  \\ Variable &  Police & guards & Home & Street\\ & [1] & [2] & [3] & [4]\\\hline \\[-2ex]")

global estout_post postfoot(" \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Preferences for Gun Ownership and Carry, binary estimation} \label{tab:Table1ed}\centering \vspace{0.35cm} \justifying \footnotesize Notes: Each column shows the regression coefficients and the robust standard errors in parentheses corresponding to OLS estimations of linear models using standardized dependent and binary overestimation independent variables. The binary overestimation index is defined as 1 when the expected number of right answers reported in the questionnaire is greater than the effective number of correct answers and 0 otherwise *** p$<$0.001, ** p$<$0.01, * p$<$0.05. Controls include: age, gender, marital status, education level, employment, trust (justice system, parliament, police, president and trust in others) and life satisfaction. All panels include controls and country fixed effects. Survey questions used for the construction of the dependent and independent variables are available in Online Appendix \ref{questions}. \end{table}" ) 

foreach y of varlist $gun_own {
	local lab: var lab `y'
	eststo: reg `y' overestim_dummy overplace_pc_std_1 $controls i.PAIS, r
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
}
estout using "$tables/TableA29.tex", $estout_pre_table $styles keep(overestim_dummy overplace_pc_std_1) stats(N r2 controls FE_country, labels( "Observations" "Adjusted-R-squared" " \midrule Controls" "Country FE") fmt(0 3 0 0)) style(tex) collabels(none) prefoot(\midrule) $estout_post replace
eststo clear	
}	

***************************************************************************
* Table A.30 Gun ownership - Binary Overestimate
***************************************************************************
{

global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.7}{ \begin{tabular}{lcccccccc} \hline \hline\\[-2ex] & \multicolumn{3}{c}{In the street}  & \multicolumn{3}{c}{At home: Alone} & \multicolumn{2}{c}{At home: With family}  \\ \cmidrule(lr){2-4} \cmidrule(lr){5-7} \cmidrule(lr){8-9} \\[-2ex] Variable & Knife & Firearm & Always & Knife & Firearm & Always & Always & Equal weapon \\ & [1] & [2] & [3] & [4] & [5] & [6] & [7] & [8] \\ \hline \\[-2ex]")

global estout_post postfoot("  \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Willingness to Offer Resistance in a Robbery, binary estimation}      \label{tab:Table2ed} \centering \vspace{0.35cm} \justifying       \footnotesize      Notes: Each column shows the regression coefficients and the robust standard errors in parentheses corresponding to a multinomial logistic model using a binary variable for overestimation. The binary overestimation index is defined as 1 when the expected number of right answers reported in the questionnaire is greater than the effective number of correct answers and 0 otherwise The base category of the dependent variables is never offering resistance   *** p$<$0.001, ** p$<$0.01, * p$<$0.05. Controls include: age, gender, marital status, education level, employment, trust (justice system, parliament, police, president and trust in others) and life satisfaction. Survey questions used for the construction of the dependent and independent variables are available in Online Appendix \ref{questions}.\end{table}" )

foreach y of varlist $gun_use {
	local lab: var lab `y'
	eststo: mlogit `y' overestim_dummy overplace_pc_std_1 $controls i.PAIS, vce(robust) baseoutcome(1)
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
}
estout using "$tables/TableA30.tex", $estout_pre_table $styles eqlabels(,none) keep(overestim_dummy overplace_pc_std_1) stats(N controls FE_country, labels( "Observations" "\midrule Controls" "Country FE") fmt(0 0 0)) style(tex) collabels(none) unstack noomitted $estout_post replace
eststo clear
}

***************************************************************************
* Table A.31 Gun ownership - Partialling out (Ortoleva et al)
***************************************************************************
{
*-----------------------------------------------------------------------------------------
* First stage (overestimation ~ right answers) Follow approach from Ortoleva et al (2015)
	
	forvalues m =2/4{
		cap gen right_answers_`m' = right_answers^`m'
		label var right_answers_`m' "(N° of correct answers)$^{`m'}$"
	}
	
	* Fourth grade polynomic estimation 
	cap drop  overestimate_residuals
	reg ocon10 right_answers right_answers_2 right_answers_3 right_answers_4, r
	predict overestimate_residuals, residuals
	label var overestimate_residuals "Overestimate (residuals)"
*-----------------------------------------------------------------------------------------

global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.8}{ \begin{tabular}{lcccc} \hline \hline\\[-2ex] &  & Security  & Citizens & Citizens  \\ Variable &  Police & guards & Home & Street\\ & [1] & [2] & [3] & [4]\\\hline \\[-2ex]")

global estout_post postfoot(" \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Gun Ownership Preferences, Partialling out} \label{tab:Table1ed}\centering \vspace{0.35cm}  \justifying       \footnotesize Notes: Each column displays the regression coefficients, with robust standard errors in parentheses, from OLS estimations of linear models. These models use standardized dependent variables and residuals of overestimation, estimated with a fourth-degree polynomial specification, comparing the expected number of correct answers to the actual number of correct answers. *** p$<$0.001, ** p$<$0.01, * p$<$0.05. Controls include: age, gender, marital status, education level, employment, trust (justice system, parliament, police and president and trust in others) and life satisfaction. All panels include controls and country fixed effects. Survey questions used for the construction of the dependent and independent variables are available in Appendix \ref{questions}.\end{table}" )
	
	foreach y of varlist $gun_own {
	local lab: var lab `y'
	eststo: reg `y' overestimate_residuals $controls i.PAIS, robust 
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
	}
	estout using "$tables/TableA31.tex", $estout_pre_table $styles keep(overestimate_residuals) stats(N r2 controls FE_country, labels( "Observations" "Adjusted-R-squared" "Controls" "Country FE") fmt(0 3 0 0)) style(tex) collabels(none) prefoot(~\\) $estout_post replace 
eststo clear
}

***************************************************************************
* Table A.32 Gun ownership - Partialling out (Ortoleva et al)
***************************************************************************
{
global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.7}{ \begin{tabular}{lcccccccc} \hline \hline\\[-2ex] & \multicolumn{3}{c}{In the street}  & \multicolumn{3}{c}{At home: Alone} & \multicolumn{2}{c}{At home: With family}  \\ \cmidrule(lr){2-4} \cmidrule(lr){5-7} \cmidrule(lr){8-9} \\[-2ex] Variable & Knife & Firearm & Always & Knife & Firearm & Always & Always & Equal weapon \\ & [1] & [2] & [3] & [4] & [5] & [6] & [7] & [8] \\ \hline \\[-2ex]")

global estout_post postfoot("  \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Willingness to Offer Resistance in a Robbery, Partialling out}      \label{tab:Table2ed} \centering \vspace{0.35cm} \justifying       \footnotesize      Notes: Each column displays the regression coefficients, with robust standard errors in parentheses, from multinomial logistic models.  Residuals of overestimation are estimated with a fourth-degree polynomial specification, comparing the expected number of correct answers to the actual number of correct answers.   *** p$<$0.001, ** p$<$0.01, * p$<$0.05. Controls include: age, gender, marital status, education level, employment, trust (justice system, parliament, police, president and trust in others) and life satisfaction. Survey questions used for the construction of the dependent and independent variables are available in Online Appendix \ref{questions}.\end{table}" )
	
foreach y of varlist $gun_use {
	local lab: var lab `y'
	eststo: mlogit `y' overestimate_residuals $controls i.PAIS, vce(robust) baseoutcome(1)
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
}
estout using "$tables/TableA32.tex", $estout_pre_table $styles eqlabels(,none) keep(overestimate_residuals) stats(N controls FE_country, labels( "Observations" "\midrule Controls" "Country FE") fmt(0 0 0)) style(tex) collabels(none) unstack noomitted $estout_post replace
eststo clear
}

******************************************************************
* Table A.33 Gun ownership - Female Heterogeneous effect
******************************************************************
{
global controls_no Age d_employed d_retired i.marital_status Elementary HighSchool College satisfaction trust_gov trust_pres trust_just trust_pol trust_others

global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.8}{ \begin{tabular}{lcccc} \hline \hline\\[-2ex] &  & Security  & Citizens & Citizens  \\ Variable &  Police & guards & Home & Street\\ & [1] & [2] & [3] & [4]\\\hline \\[-2ex]")
global estout_post postfoot(" \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Preferences for Gun Ownership and Carry, Heterogeneous by gender} \label{tab:Table1ed}\centering \vspace{0.35cm} \justifying \footnotesize Notes: Each column shows the regression coefficients and the robust standard errors in parentheses corresponding to OLS estimations of linear models using both standardized dependent and independent variables. *** p$<$0.001, ** p$<$0.01, * p$<$0.05. Controls include: age, marital status, education level, employment, trust (justice system, parliament, police and president and trust in others) and life satisfaction.  Survey questions used for the construction of the dependent and independent variables are available in Online Appendix \ref{questions}. \end{table}" ) 

foreach y of varlist $gun_own {
	local lab: var lab `y'
	eststo: reg `y' i.Female c.overestimation_std##i.Female c.overplace_pc_std_1##i.Female  i.PAIS $controls_no, r
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
}
estout using "$tables/TableA33.tex", $estout_pre_table cells(b(star fmt(2)) se(par fmt(2))) starlevels(* .05 ** .01 *** .001) label mlabels(,none) keep(overestimation_std overplace_pc_std_1 1.Female 1.Female#c.overestimation_std 1.Female#c.overplace_pc_std_1) varlabels(_cons Constant 1.Female "Female = 1" 1.Female#c.overestimation_std  "Overestimation$^{1}$ (std) $\times$ Female = 1"  1.Female#c.overplace_pc_std_1 "Overplacement$^{1}$ (PCA, std) $\times$ Female = 1") stats(N r2 controls FE_country, labels( "Observations" "Adjusted-R-squared" " \midrule Controls" "Country FE") fmt(0 3 0 0)) style(tex) collabels(none) prefoot(\midrule) $estout_post replace
eststo clear	
}	

***************************************************************************
* Table A.34 Gun ownership - Female Heterogeneous effect
***************************************************************************
{
global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.6}{ \begin{tabular}{lcccccccc} \hline \hline\\[-2ex] & \multicolumn{3}{c}{In the street}  & \multicolumn{3}{c}{At home: Alone} & \multicolumn{2}{c}{At home: With family}  \\ \cmidrule(lr){2-4} \cmidrule(lr){5-7} \cmidrule(lr){8-9} \\[-2ex] Variable & Knife & Firearm & Always & Knife & Firearm & Always & Always & Equal weapon \\ & [1] & [2] & [3] & [4] & [5] & [6] & [7] & [8] \\ \hline \\[-2ex]")

global estout_post postfoot("  \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Willingness to Offer Resistance in a Robbery, Heterogeneous effect by gender}      \label{tab:Table2ed} \centering \vspace{0.35cm} \justifying       \footnotesize      Notes: Each column shows the regression coefficients and the robust standard errors in parentheses corresponding to a multinomial logistic model using standardized independent variables. The base category of the dependent variables is never offering resistance   *** p$<$0.001, ** p$<$0.01, * p$<$0.05. Controls include: age, marital status, education level, employment, trust (justice system, parliament, police and president and trust in others) and life satisfaction. Survey questions used for the construction of the dependent and independent variables are available in Online Appendix \ref{questions}.\end{table}" )

foreach y of varlist $gun_use {
	local lab: var lab `y'
	eststo: mlogit `y' i.Female c.overestimation_std##i.Female c.overplace_pc_std_1##i.Female  i.PAIS $controls_no, vce(robust) baseoutcome(1)
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
}
estout using "$tables/TableA34.tex", $estout_pre_table  eqlabels(,none) cells(b(star fmt(2)) se(par fmt(2))) starlevels(* .05 ** .01 *** .001) label mlabels(,none) keep(overestimation_std overplace_pc_std_1 1.Female 1.Female#c.overestimation_std 1.Female#c.overplace_pc_std_1) varlabels(_cons Constant 1.Female "Female = 1" 1.Female#c.overestimation_std  "Overestimation$^{1}$ (std) $\times$ Female = 1"  1.Female#c.overplace_pc_std_1 "Overplacement$^{1}$ (PCA, std) $\times$ Female = 1") stats(N controls FE_country, labels( "Observations" "\midrule Controls" "Country FE") fmt(0 0 0)) style(tex) collabels(none) unstack noomitted $estout_post replace
eststo clear
}

***************************************************
* Table A.35 Gun ownership - Ordered Logit 
***************************************************
{
	local replace "replace"
	foreach y of varlist $gun_own {
		ologit `y' overestimation_std overplace_pc_std_1 $controls i.PAIS, vce(robust)
		outreg2 using "$tables/TableA35", `replace' tex(frag) bdec(2) sdec(2) slow(100) addtext(Controls, Yes, Country FE, Yes) drop($controls i.PAIS) nocons	
	local replace " "
	}
}

******************************************************************
* Table A.36 Gun ownership - Leaving out country
******************************************************************
{	
global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.6}{ \begin{tabular}{lcccc} \hline \hline\\[-2ex] &  & Security  & Citizens & Citizens  \\ Variable &  Police & guards & Home & Street\\ & [1] & [2] & [3] & [4]\\\hline \\[-2ex] \multicolumn{5}{l}{\bf Panel A: Without Argentina} \\ ")

global estout_post postfoot(" \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Preferences for Gun Ownership and Carry. Leave-One-Out Regressions} \label{tab:Table1ed}\centering \vspace{0.35cm} \justifying \footnotesize Notes: Each column shows the regression coefficients and the robust standard errors in parentheses corresponding to OLS estimations of linear models using standardized dependent and independent variables. *** p$<$0.001, ** p$<$0.01, * p$<$0.05. Controls include: age, gender, marital status, education level, employment, trust (justice system, parliament, police, president and trust in others) and life satisfaction. All panels include controls and country fixed effects. Survey questions used for the construction of the dependent and independent variables are available in Online Appendix \ref{questions}. \end{table}" ) 

global Panel_B prehead("\multicolumn{5}{l}{\bf Panel B: Without Brazil} \\")
global Panel_C prehead("\multicolumn{5}{l}{\bf Panel C: Without Chile} \\")
global Panel_D prehead("\multicolumn{5}{l}{\bf Panel D: Without Colombia} \\")
global Panel_E prehead("\multicolumn{5}{l}{\bf Panel D: Without Mexico} \\")
global Panel_F prehead("\multicolumn{5}{l}{\bf Panel D: Without USA} \\")

*----------------------------------------	
* Panel A: No Argentina
*---------------------------------------
foreach y of varlist $gun_own {
	local lab: var lab `y'
	eststo: reg `y' overestimation_std overplace_pc_std_1 $controls i.PAIS if PAIS != 1, robust
}
estout using "$tables/TableA36.tex", $estout_pre_table $styles keep(overestimation_std overplace_pc_std_1) stats(N r2, labels( "Observations" "Adjusted-R-squared") fmt(0 3)) style(tex) collabels(none) prefoot(~\\) postfoot(\midrule) replace
eststo clear
*----------------------------------------	
* Panel B: No Brazil
*---------------------------------------
foreach y of varlist $gun_own {
	local lab: var lab `y'
	eststo: reg `y' overestimation_std overplace_pc_std_1 $controls i.PAIS if PAIS != 2, robust
}
estout using "$tables/TableA36.tex", $Panel_B $styles keep(overestimation_std overplace_pc_std_1) stats(N r2, labels( "Observations" "Adjusted-R-squared") fmt(0 3)) style(tex) collabels(none) prefoot(~\\) postfoot(\midrule) append 
eststo clear
*----------------------------------------	
* Panel C: No Chile
*---------------------------------------
foreach y of varlist $gun_own {
	local lab: var lab `y'
	eststo: reg `y' overestimation_std overplace_pc_std_1 $controls i.PAIS if PAIS != 3, robust
}
estout using "$tables/TableA36.tex", $Panel_C $styles keep(overestimation_std overplace_pc_std_1) stats(N r2, labels( "Observations" "Adjusted-R-squared") fmt(0 3)) style(tex) collabels(none) prefoot(~\\) postfoot(\midrule) append 
eststo clear
*--------------------------------------------
* Panel D: No Colombia
*--------------------------------------------
foreach y of varlist $gun_own  {
	local lab: var lab `y'
	eststo: reg `y' overestimation_std overplace_pc_std_1 $controls i.PAIS if PAIS != 4, robust
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
}
estout using "$tables/TableA36.tex", $Panel_D $styles keep(overestimation_std overplace_pc_std_1) stats(N r2, labels( "Observations" "Adjusted-R-squared" ) fmt(0 3)) style(tex) collabels(none) prefoot(~\\) postfoot(\midrule) append 
eststo clear	
*--------------------------------------------
* Panel E: No Mexico
*--------------------------------------------
foreach y of varlist $gun_own  {
	local lab: var lab `y'
	eststo: reg `y' overestimation_std overplace_pc_std_1 $controls i.PAIS if PAIS != 5, robust
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
}
estout using "$tables/TableA36.tex", $Panel_E $styles keep(overestimation_std overplace_pc_std_1) stats(N r2, labels( "Observations" "Adjusted-R-squared" ) fmt(0 3)) style(tex) collabels(none) prefoot(~\\) postfoot(\midrule) append 
eststo clear
*--------------------------------------------
* Panel F: No USA
*--------------------------------------------
foreach y of varlist $gun_own  {
	local lab: var lab `y'
	eststo: reg `y' overestimation_std overplace_pc_std_1 $controls i.PAIS if PAIS != 6, robust
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
}
estout using "$tables/TableA36.tex", $Panel_F $styles keep(overestimation_std overplace_pc_std_1) stats(N r2 controls FE_country, labels( "Observations" "Adjusted-R-squared" " \hline Controls" "Country FE") fmt(0 3 0 0)) style(tex) collabels(none) prefoot(~\\) $estout_post append 
eststo clear
}

******************************************************************
* Table A.37 Gun ownership - Leaving out country
******************************************************************
{
	
global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.6}{ \begin{tabular}{lcccccccc} \hline \hline\\[-2ex] & \multicolumn{3}{c}{In the street}  & \multicolumn{3}{c}{At home: Alone} & \multicolumn{2}{c}{At home: With family}  \\ \cmidrule(lr){2-4} \cmidrule(lr){5-7} \cmidrule(lr){8-9} \\[-2ex] Variable & Knife & Firearm & Always & Knife & Firearm & Always & Always & Equal weapon \\ & [1] & [2] & [3] & [4] & [5] & [6] & [7] & [8] \\ \hline \\[-2ex]\multicolumn{11}{l}{\bf Panel A: Responsibility} \\")

global estout_post postfoot("  \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Willingness to Offer Resistance in a Robbery. Leave-One-Out Regressions}      \label{tab:Table2ed} \centering \vspace{0.35cm} \justifying       \footnotesize      Notes: Each column shows the regression coefficients and the robust standard errors in parentheses corresponding to a multinomial logistic model using the standardized overestimation index. The base category of the dependent variables is never offering resistance.    *** p$<$0.001, ** p$<$0.01, * p$<$0.05.      Controls include: age, gender, marital status, education level, employment, trust (justice system, parliament, police, president and trust in others) and life satisfaction. All panels include controls and country fixed effects. Survey questions used for the construction of the dependent and independent variables are available in Online Appendix \ref{questions}.\end{table}" )

global Panel_B prehead("\multicolumn{11}{l}{\bf Panel B: Without Brazil} \\")
global Panel_C prehead("\multicolumn{11}{l}{\bf Panel C: Without Chile} \\")
global Panel_D prehead("\multicolumn{11}{l}{\bf Panel D: Without Colombia} \\")
global Panel_E prehead("\multicolumn{11}{l}{\bf Panel D: Without Mexico} \\")
global Panel_F prehead("\multicolumn{11}{l}{\bf Panel D: Without USA} \\")

*----------------------------------------	
* Panel A: No Argentina
*---------------------------------------
local j = 1
foreach y of varlist $gun_use {
	local lab: var lab `y'
	mlogit `y' overestimation_std overplace_pc_std_1  $controls i.PAIS if PAIS != 1, vce(robust) baseoutcome(1)
	estimate store store`j'
	local ++j
}
estout store1 store2 store3 using "$tables/TableA37.tex", $estout_pre_table $styles eqlabels(,none) keep(overestimation_std overplace_pc_std_1) stats(N, labels( "Observations") fmt(0)) style(tex) collabels(none) unstack noomitted postfoot(\midrule) replace
eststo clear
*----------------------------------------	
* Panel B: No Brazil
*---------------------------------------
local j = 1
foreach y of varlist $gun_use {
	local lab: var lab `y'
	mlogit `y' overestimation_std overplace_pc_std_1  $controls i.PAIS if PAIS != 2, vce(robust) baseoutcome(1)
	estimate store store`j'
	local ++j
}
estout store1 store2 store3 using "$tables/TableA37.tex", $Panel_B $styles eqlabels(,none) keep(overestimation_std overplace_pc_std_1) stats(N, labels( "Observations") fmt(0)) style(tex) collabels(none) unstack noomitted postfoot(\midrule) append
eststo clear
*----------------------------------------	
* Panel C: No Chile
*---------------------------------------
local j = 1
foreach y of varlist $gun_use {
	local lab: var lab `y'
	mlogit `y' overestimation_std overplace_pc_std_1  $controls i.PAIS if PAIS != 3, vce(robust) baseoutcome(1)
	estimate store store`j'
	local ++j
}
estout store1 store2 store3 using "$tables/TableA37.tex", $Panel_C $styles eqlabels(,none) keep(overestimation_std overplace_pc_std_1) stats(N, labels( "Observations") fmt(0)) style(tex) collabels(none) unstack noomitted postfoot(\midrule) append
eststo clear
*----------------------------------------	
* Panel D: No Colombia
*---------------------------------------
local j = 1
foreach y of varlist $gun_use {
	local lab: var lab `y'
	mlogit `y' overestimation_std overplace_pc_std_1  $controls i.PAIS if PAIS != 4, vce(robust) baseoutcome(1)
	estimate store store`j'
	local ++j
}
estout store1 store2 store3 using "$tables/TableA37.tex", $Panel_D $styles eqlabels(,none) keep(overestimation_std overplace_pc_std_1) stats(N, labels( "Observations") fmt(0)) style(tex) collabels(none) unstack noomitted postfoot(\midrule) append
eststo clear
*----------------------------------------	
* Panel E: No Mexico
*---------------------------------------
local j = 1
foreach y of varlist $gun_use {
	local lab: var lab `y'
	mlogit `y' overestimation_std overplace_pc_std_1  $controls i.PAIS if PAIS != 5, vce(robust) baseoutcome(1)
	estimate store store`j'
	local ++j
}
estout store1 store2 store3 using "$tables/TableA37.tex", $Panel_E $styles eqlabels(,none) keep(overestimation_std overplace_pc_std_1) stats(N, labels( "Observations") fmt(0)) style(tex) collabels(none) unstack noomitted postfoot(\midrule) append
eststo clear
*--------------------------------------------
* Panel F: No USA
*--------------------------------------------
foreach y of varlist $gun_use {
	local lab: var lab `y'
	eststo: mlogit `y' overestimation_std overplace_pc_std_1  $controls i.PAIS if PAIS != 6, vce(robust) baseoutcome(1)
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
}
estout using "$tables/TableA37.tex", $Panel_F $styles eqlabels(,none) keep(overestimation_std overplace_pc_std_1) stats(N controls FE_country, labels( "Observations" "\hline Controls" "Country FE") fmt(0 0 0)) style(tex) collabels(none) unstack noomitted $estout_post append 
eststo clear
}

******************************************************************
* Table A.38 Gun ownership - Math questions Heterogeneous effect
******************************************************************
{
global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.8}{ \begin{tabular}{lcccc} \hline \hline\\[-2ex] &  & Security  & Citizens & Citizens  \\ Variable &  Police & guards & Home & Street\\ & [1] & [2] & [3] & [4]\\\hline \\[-2ex]")
global estout_post postfoot(" \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Preferences for Gun Ownership and Carry, Heterogeneity by Performance in Math Questions} \label{tab:Table1ed}\centering \vspace{0.35cm} \justifying \footnotesize Notes: Each column shows the regression coefficients and the robust standard errors in parentheses corresponding to OLS estimations of linear models using both standardized dependent and independent variables. *** p$<$0.001, ** p$<$0.01, * p$<$0.05. Controls include: age, gender, marital status, education level, employment, trust (justice system, parliament, police and president and trust in others) and life satisfaction.  Survey questions used for the construction of the dependent and independent variables are available in Online Appendix \ref{questions}. \end{table}" ) 

foreach y of varlist $gun_own {
	local lab: var lab `y'
	eststo: reg `y' i.OK_MT c.overestimation_std##i.OK_MT c.overplace_pc_std_1##i.OK_MT  i.PAIS $controls, r
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
}
estout using "$tables/TableA38.tex", $estout_pre_table cells(b(star fmt(2)) se(par fmt(2))) starlevels(* .05 ** .01 *** .001) label mlabels(,none) keep(overestimation_std overplace_pc_std_1 1.OK_MT 1.OK_MT#c.overestimation_std 1.OK_MT#c.overplace_pc_std_1) varlabels(_cons Constant 1.OK_MT "Succeds in math questions" 1.OK_MT#c.overestimation_std  "Overestimation$^{1}$ (std) $\times$ Succeds in math q."  1.OK_MT#c.overplace_pc_std_1 "Overplacement$^{1}$ (PCA, std) $\times$ Succeds in math q.") stats(N r2 controls FE_country, labels( "Observations" "Adjusted-R-squared" " \midrule Controls" "Country FE") fmt(0 3 0 0)) style(tex) collabels(none) prefoot(\midrule) $estout_post replace
eststo clear	
}	

***************************************************************************
* Table A.39 Gun ownership - Math questions Heterogeneous effect
***************************************************************************
{
global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.6}{ \begin{tabular}{lcccccccc} \hline \hline\\[-2ex] & \multicolumn{3}{c}{In the street}  & \multicolumn{3}{c}{At home: Alone} & \multicolumn{2}{c}{At home: With family}  \\ \cmidrule(lr){2-4} \cmidrule(lr){5-7} \cmidrule(lr){8-9} \\[-2ex] Variable & Knife & Firearm & Always & Knife & Firearm & Always & Always & Equal weapon \\ & [1] & [2] & [3] & [4] & [5] & [6] & [7] & [8] \\ \hline \\[-2ex]")

global estout_post postfoot("  \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Willingness to Offer Resistance in a Robbery, Heterogeneity by Performance in Math Questions }      \label{tab:Table2ed} \centering \vspace{0.35cm} \justifying       \footnotesize      Notes: Each column shows the regression coefficients and the robust standard errors in parentheses corresponding to a multinomial logistic model using standardized independent variables. The base category of the dependent variables is never offering resistance   *** p$<$0.001, ** p$<$0.01, * p$<$0.05. Controls include: age, gender, marital status, education level, employment, trust (justice system, parliament, police and president and trust in others) and life satisfaction. Survey questions used for the construction of the dependent and independent variables are available in Online Appendix \ref{questions}.\end{table}" )

foreach y of varlist $gun_use {
	local lab: var lab `y'
	eststo: mlogit `y' i.OK_MT c.overestimation_std##i.OK_MT c.overplace_pc_std_1##i.OK_MT i.PAIS $controls, vce(robust) baseoutcome(1)
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
}
estout using "$tables/TableA39.tex", $estout_pre_table  eqlabels(,none) cells(b(star fmt(2)) se(par fmt(2))) starlevels(* .05 ** .01 *** .001) label mlabels(,none) keep(overestimation_std overplace_pc_std_1 1.OK_MT 1.OK_MT#c.overestimation_std 1.OK_MT#c.overplace_pc_std_1) varlabels(_cons Constant 1.OK_MT "Succeds in math questions" 1.OK_MT#c.overestimation_std  "Overestimation$^{1}$ (std) $\times$ Succeds in math q."  1.OK_MT#c.overplace_pc_std_1 "Overplacement$^{1}$ (PCA, std) $\times$ Succeds in math q.") stats(N controls FE_country, labels( "Observations" "\midrule Controls" "Country FE") fmt(0 0 0)) style(tex) collabels(none) unstack noomitted $estout_post replace
eststo clear
}

******************************************************************
* Table A.40 Gun ownership - Actual performance in math
******************************************************************
{
	
global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.8}{ \begin{tabular}{lcccc} \hline \hline\\[-2ex] &  & Security  & Citizens & Citizens  \\ Variable &  Police & guards & Home & Street\\ & [1] & [2] & [3] & [4]\\\hline \\[-2ex] \multicolumn{5}{l}{\bf Panel A: Estimated number of right answers in end question} \\ ")

global estout_post postfoot(" \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Preferences for Gun Ownership and Carry. Heterogeneity by Number of Right Answers} \label{tab:Table1ed}\centering \vspace{0.35cm} \justifying \footnotesize Notes: Each column shows the regression coefficients and the robust standard errors in parentheses corresponding to OLS estimations of linear models using standardized dependent and independent variables. The estimated number of right answers is the answer to the explicit estimation question in panel A, and the number of individually estimated right answers (as somewhat or very confident) in panel B. The sample is restricted to the number of effective answers that individually gather at least 10\% of the respondents for sample size purposes. As the estimated number of right answers is not included individually in the specification, the interaction coefficients can be interpreted as the individual effect of this variable conditional on the specific number of effective right answers *** p$<$0.001, ** p$<$0.01, * p$<$0.05. Controls include: age, gender, marital status, education level, employment, trust (justice system, parliament, police, president and trust in others) and life satisfaction. All panels include controls and country fixed effects. Survey questions used for the construction of the dependent and independent variables are available in Online Appendix \ref{questions}. \end{table}" ) 

global Panel_B prehead("\multicolumn{5}{l}{\bf Panel B: Estimated number of right answers question by question} \\")

*----------------------------------------	
* Panel A:  Estimated number of right answers in end question
*---------------------------------------
foreach y of varlist $gun_own {
	local lab: var lab `y'
	eststo: reg `y' c.ocon10#i.right_answers i.right_answers overplace_pc_std_1 $controls i.PAIS if inrange(right_answers, 4, 8), r
}
estout using "$tables/TableA40.tex", $estout_pre_table cells(b(star fmt(2)) se(par fmt(2))) starlevels(* .05 ** .01 *** .001) label mlabels(,none) keep( overplace_pc_std_1 4.right_answers#c.ocon10 5.right_answers#c.ocon10 6.right_answers#c.ocon10 7.right_answers#c.ocon10 8.right_answers#c.ocon10) varlabels(_cons Constant 4.right_answers#c.ocon10  "Estimated number $\times$ Four right answers"  5.right_answers#c.ocon10 "Estimated number $\times$ Five right answers" 6.right_answers#c.ocon10 " Estimated number $\times$ Six right answers" 7.right_answers#c.ocon10 "Estimated number $\times$ Seven right answers"  8.right_answers#c.ocon10 "Estimated number $\times$ Eight right answers" ) stats(N r2, labels( "Observations" "Adjusted-R-squared") fmt(0 3)) style(tex) collabels(none) prefoot(~\\) postfoot(\midrule) replace
eststo clear
*--------------------------------------------
* Panel B: Estimated number of right answers question by question
*--------------------------------------------
foreach y of varlist $gun_own {
	local lab: var lab `y'
	eststo: reg `y' c.ocon10_c#i.right_answers i.right_answers overplace_pc_std_1 $controls i.PAIS if inrange(right_answers, 4, 8) , r
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
}
estout using "$tables/TableA40.tex", $Panel_B cells(b(star fmt(2)) se(par fmt(2))) starlevels(* .05 ** .01 *** .001) label mlabels(,none) keep( overplace_pc_std_1 4.right_answers#c.ocon10_c 5.right_answers#c.ocon10_c 6.right_answers#c.ocon10_c 7.right_answers#c.ocon10_c 8.right_answers#c.ocon10_c) varlabels(_cons Constant 4.right_answers#c.ocon10_c  "Estimated number $\times$ Four right answers"  5.right_answers#c.ocon10_c "Estimated number $\times$ Five right answers" 6.right_answers#c.ocon10_c " Estimated number $\times$ Six right answers" 7.right_answers#c.ocon10_c "Estimated number $\times$ Seven right answers"  8.right_answers#c.ocon10_c "Estimated number $\times$ Eight right answers" ) stats(N r2 controls FE_country, labels( "Observations" "Adjusted-R-squared" " \midrule Controls" "Country FE") fmt(0 3 0 0)) style(tex) collabels(none) prefoot(~\\)  append $estout_post
eststo clear	
}

*******************************************************************
* Table A.41 Gun ownership - Actual performance in math
*******************************************************************
{
global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.65}{ \begin{tabular}{lcccccccc} \hline \hline\\[-2ex] & \multicolumn{3}{c}{In the street}  & \multicolumn{3}{c}{At home: Alone} & \multicolumn{2}{c}{At home: With family}  \\ \cmidrule(lr){2-4} \cmidrule(lr){5-7} \cmidrule(lr){8-9} \\[-2ex] Variable & Knife & Firearm & Always & Knife & Firearm & Always & Always & Equal weapon \\ & [1] & [2] & [3] & [4] & [5] & [6] & [7] & [8] \\ \hline \\[-2ex]\multicolumn{11}{l}{\bf Panel A: Estimated number of right answers in end question} \\")

global estout_post postfoot("  \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Willingness to Offer Resistance in a Robbery}      \label{tab:Table2ed} \centering \vspace{0.35cm} \justifying       \footnotesize      Notes: Each column shows the regression coefficients and the robust standard errors in parentheses corresponding to a multinomial logistic model using the standardized overestimation index and binary indicators for each component of overplacement, which take the value 1 when the respondent express being above the average citizen in that dimension. he base category of the dependent variables is never offering resistance.    *** p$<$0.001, ** p$<$0.01, * p$<$0.05.      Controls include: age, gender, marital status, education level, employment, trust (justice system, parliament, police, president and trust in others) and life satisfaction. All panels include controls and country fixed effects. Percentage of answers denote the total of participant that respond the question with that answer. Survey questions used for the construction of the dependent and independent variables are available in Online Appendix \ref{questions}.\end{table}" )

global Panel_B prehead("\multicolumn{11}{l}{\bf Panel B: Estimated number of right answers question by question} \\")

*---------------------------------------
* Panel A: Estimated number of right answers in end question
*---------------------------------------
local j = 1
foreach y of varlist $gun_use {
	local lab: var lab `y'
	mlogit `y' c.ocon10#i.right_answers i.right_answers overplace_pc_std_1 $controls i.PAIS if inrange(right_answers, 4, 8), vce(robust) baseoutcome(1)
	estimate store store`j'
	local ++j
}
estout store1 store2 store3 using "$tables/TableA41.tex", $estout_pre_table cells(b(star fmt(2)) se(par fmt(2))) starlevels(* .05 ** .01 *** .001) label mlabels(,none) keep( overplace_pc_std_1 4.right_answers#c.ocon10 5.right_answers#c.ocon10 6.right_answers#c.ocon10 7.right_answers#c.ocon10 8.right_answers#c.ocon10) varlabels(_cons Constant 4.right_answers#c.ocon10  "Estimated number $\times$ Four right answers"  5.right_answers#c.ocon10 "Estimated number $\times$ Five right answers" 6.right_answers#c.ocon10 " Estimated number $\times$ Six right answers" 7.right_answers#c.ocon10 "Estimated number $\times$ Seven right answers"  8.right_answers#c.ocon10 "Estimated number $\times$ Eight right answers" ) eqlabels(,none) stats(N, labels( "Observations") fmt(0)) style(tex) collabels(none) unstack noomitted postfoot(\midrule) replace
eststo clear

*--------------------------------------------
* Panel B: Estimated number of right answers question by question
*--------------------------------------------
foreach y of varlist $gun_use {
	local lab: var lab `y'
	eststo: mlogit `y' c.ocon10_c#i.right_answers i.right_answers overplace_pc_std_1 $controls i.PAIS if inrange(right_answers, 4, 8), vce(robust) baseoutcome(1)
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
}
estout using "$tables/TableA41.tex", $Panel_B eqlabels(,none) cells(b(star fmt(2)) se(par fmt(2))) starlevels(* .05 ** .01 *** .001) label mlabels(,none) keep( overplace_pc_std_1 4.right_answers#c.ocon10_c 5.right_answers#c.ocon10_c 6.right_answers#c.ocon10_c 7.right_answers#c.ocon10_c 8.right_answers#c.ocon10_c) varlabels(_cons Constant 4.right_answers#c.ocon10_c  "Estimated number $\times$ Four right answers"  5.right_answers#c.ocon10_c "Estimated number $\times$ Five right answers" 6.right_answers#c.ocon10_c " Estimated number $\times$ Six right answers" 7.right_answers#c.ocon10_c "Estimated number $\times$ Seven right answers"  8.right_answers#c.ocon10_c "Estimated number $\times$ Eight right answers" ) stats(N controls FE_country, labels( "Observations" "\hline Controls" "Country FE") fmt(0 0 0)) style(tex) collabels(none) unstack noomitted $estout_post append 
eststo clear
}

***********************************************************************
* Table A.42 Gun ownership - Binary Overestimate (Overestimate > 1)
***********************************************************************
{
	
label var overestim_dummy_2 "Overestimation$^{2}$ (binary)"
	
global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.8}{ \begin{tabular}{lcccc} \hline \hline\\[-2ex] &  & Security  & Citizens & Citizens  \\ Variable &  Police & guards & Home & Street\\ & [1] & [2] & [3] & [4]\\\hline \\[-2ex]")

global estout_post postfoot(" \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Preferences for Gun Ownership and Carry, binary estimation (Overestimation $\geq$ 2)} \label{tab:Table1ed}\centering \vspace{0.35cm} \justifying \footnotesize Notes: Each column shows the regression coefficients and the robust standard errors in parentheses corresponding to OLS estimations of linear models using standardized dependent and binary overestimation independent variables. The binary overestimation index is defined as 1 when the expected number of right answers reported in the questionnaire is greater by at least 2 than the effective number of correct answers and 0 if they underestimate their answers. *** p$<$0.001, ** p$<$0.01, * p$<$0.05. Controls include: age, gender, marital status, education level, employment, trust (justice system, parliament, police, president and trust in others) and life satisfaction. All estimates controls and country fixed effects. Survey questions used for the construction of the dependent and independent variables are available in Online Appendix \ref{questions}. \end{table}" ) 

foreach y of varlist $gun_own {
	local lab: var lab `y'
	eststo: reg `y' overestim_dummy_2 overplace_pc_std_1 $controls i.PAIS, r
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
}
estout using "$tables/TableA42.tex", $estout_pre_table $styles keep(overestim_dummy_2 overplace_pc_std_1) stats(N r2 controls FE_country, labels( "Observations" "Adjusted-R-squared" " \midrule Controls" "Country FE") fmt(0 3 0 0)) style(tex) collabels(none) prefoot(\midrule) $estout_post replace
eststo clear	
}	

***************************************************************************
* Table A.43 Gun ownership - Binary Overestimate
***************************************************************************
{

global estout_pre_table prehead("\begin{table}[H] \centering \scalebox{0.7}{ \begin{tabular}{lcccccccc} \hline \hline\\[-2ex] & \multicolumn{3}{c}{In the street}  & \multicolumn{3}{c}{At home: Alone} & \multicolumn{2}{c}{At home: With family}  \\ \cmidrule(lr){2-4} \cmidrule(lr){5-7} \cmidrule(lr){8-9} \\[-2ex] Variable & Knife & Firearm & Always & Knife & Firearm & Always & Always & Equal weapon \\ & [1] & [2] & [3] & [4] & [5] & [6] & [7] & [8] \\ \hline \\[-2ex]")

global estout_post postfoot("  \hline \hline\\[-2ex] \end{tabular} } \caption{Overconfidence and Willingness to Offer Resistance in a Robbery, binary estimation (Overestimation $\geq$ 2)}      \label{tab:Table2ed} \centering \vspace{0.35cm} \justifying     \footnotesize  Notes: Each column shows the regression coefficients and the robust standard errors in parentheses corresponding to a multinomial logistic model using a binary variable for overestimation. The binary overestimation index is defined as 1 when the expected number of right answers reported in the questionnaire is greater by at least 2 than the effective number of correct answers and 0 if they underestimate their answers. The base category of the dependent variables is never offering resistance   *** p$<$0.001, ** p$<$0.01, * p$<$0.05. Controls include: age, gender, marital status, education level, employment, trust (justice system, parliament, police, president and trust in others) and life satisfaction. Survey questions used for the construction of the dependent and independent variables are available in Online Appendix \ref{questions}.\end{table}" )

foreach y of varlist $gun_use {
	local lab: var lab `y'
	eststo: mlogit `y' overestim_dummy_2 overplace_pc_std_1 $controls i.PAIS, vce(robust) baseoutcome(1)
		qui estadd local controls = "Yes"
		qui estadd local FE_country = "Yes"
}
estout using "$tables/TableA43.tex", $estout_pre_table $styles eqlabels(,none) keep(overestim_dummy_2 overplace_pc_std_1) stats(N controls FE_country, labels( "Observations" "\midrule Controls" "Country FE") fmt(0 0 0)) style(tex) collabels(none) unstack noomitted $estout_post replace
eststo clear
}


******************************************************
* Figure A. Scatter: Overestimate with Preferences 
******************************************************
preserve

lab var arm3_std "Standardized - Police"
lab var arm4_std "Standardized - Security Guards"
lab var arm5_std "Standardized - Citizens Home"
lab var arm6_std "Standardized - Citizens Street"

lab var overestimation_std "Standardized - Overestimation{superscript:1}"

foreach m of varlist $gun_own {
scatterfit `m' overestimation_std, binned ci regparameter(coef pval sig) opts(legend(pos(6) col(4))) controls(Age d_employed d_retired trust_gov trust_pres trust_just trust_pol trust_others) fcontrols(Female marital_status Elementary HighSchool College satisfaction PAIS) vce(robust)

graph export "$figures/effect_`m'.pdf", replace
}
restore

******************************************************
* Figure A. Scatter: Overplacement with Preferences 
******************************************************
preserve

lab var arm3_std "Standardized - Police"
lab var arm4_std "Standardized - Security Guards"
lab var arm5_std "Standardized - Citizens Home"
lab var arm6_std "Standardized - Citizens Street"

lab var overplace_pc_std_1 "Standardized - Overplacement{superscript:1}"

foreach m of varlist $gun_own {
scatterfit `m' overplace_pc_std_1, binned ci regparameter(coef pval sig) opts(legend(pos(6) col(4))) controls(Age d_employed d_retired trust_gov trust_pres trust_just trust_pol trust_others) fcontrols(Female marital_status Elementary HighSchool College satisfaction PAIS) vce(robust)

graph export "$figures/effect_`m'_overplace.pdf", replace
}
restore


***********************************************************************
* Figure A6. Coefplot with comparison of overestimation by question 
***********************************************************************

forvalues i = 1/9{
	cap label var ocon`i'c_d "Q`i'"
}

reg overestimation ocon1c_d ocon2c_d ocon3c_d ocon4c_d ocon5c_d ocon6c_d ocon7c_d ocon8c_d ocon9c_d i.PAIS $controls, r
estimates store coef1 

#delimit ;
coefplot (coef1, ciopt(recast(rcap) color(black) lwidth(thin)) msymbol(circle) mcolor(black) color(black)),
	vertical keep(ocon1c_d ocon2c_d ocon3c_d ocon4c_d ocon5c_d ocon6c_d ocon7c_d ocon8c_d ocon9c_d) label 
	yline(0, lcolor(red) lpattern(dash)) xtitle("Has confidence in answering correct the question ({it:dummy})", margin(medsmall)) 
	ytitle("Overestimation{superscript:1} Index")
;
#delimit cr	

graph export "$figures/overestimation_by_last_questions.png", replace


* Significance test
reg overestimation ocon1c_d ocon2c_d ocon3c_d ocon4c_d ocon5c_d ocon6c_d ocon7c_d ocon8c_d ocon9c_d i.PAIS $controls, r
test ocon1c_d = ocon9c_d

*********************************************************
* Figure A7. Histogram of confidence in questions correctly answered 
*********************************************************

* Create average of interest 
set scheme white_tableau
cap egen mean_2 = rowmean(ocon1c_d ocon2c_d ocon3c_d ocon4c_d ocon5c_d ocon6c_d ocon7c_d ocon8c_d ocon9c_d)
cap sum mean_2
local mean_confidence = `r(mean)'
local mean_value = string(`r(mean)', "%4.3f")

graph bar ocon1c_d ocon2c_d ocon3c_d ocon4c_d ocon5c_d ocon6c_d ocon7c_d ocon8c_d ocon9c_d, ///
    blabel(bar, format(%9.2f)) ///
    legend(order(1 "Q1" 2 "Q2" 3 "Q3" 4 "Q4" 5 "Q5" 6 "Q6" 7 "Q7" 8 "Q8" 9 "Q9") row(1) size(vsmall) pos(6)) ///
    ytitle("Percentage", margin(medium) size(small)) ///
	ysc(range(0(0.2)1)) ylabel(0(0.2)1) ///
    bar(1, fcolor(gs13) lcolor(gs13)) bar(2, fcolor(gs12) lcolor(gs12)) bar(3, fcolor(gs11) lcolor(gs11)) ///
    bar(4, fcolor(gs10) lcolor(gs10)) bar(5, fcolor(gs9) lcolor(gs9)) bar(6, fcolor(gs8) lcolor(gs8)) ///
    bar(7, fcolor(gs6) lcolor(gs6)) bar(8, fcolor(gs4) lcolor(gs4)) bar(9, fcolor(gs2) lcolor(gs2)) ///
    title("Confidence in Correct Answers by Question", size(medium)) ///
	yline(`mean_confidence', lcolor(cranberry) lpattern(solid)) text(0.76 4 "Mean = `mean_value'", size(vsmall) color(cranberry))
drop mean_2 

graph export "$figures/overconfidence_by_question.png", replace


*==========================
* Correlation matrix 
*==========================	
eststo clear
pwcorr nmor1 nmor2 nmor3 nmor4, sig star(0.01)
mat correlation = r(C)
esttab matrix(correlation) using "Corr_matrix.tex", replace unstack compress b(3)

	
	
	
**#*===* 2.14. Appendix 4 (PCA for overplacement)

pca nmor1 nmor2 nmor3
	mat def PCA = ((e(L), e(Psi)') \ (e(Ev), 0))
estat kmo
	mat def PCA = (PCA, r(kmow))

// ssc install factortest
factortest nmor1 nmor2 nmor3

// 	Bartlett test of sphericity
//		
// 	Chi-square         =          1599.275
// 	Degrees of freedom =                 3
// 	p-value            =             0.000
// 	H0: variables are not intercorrelated

frmttable using "PCA_overplace", ///
	statmat(PCA) sdec(3) ///
	rti("Responsibility" \ "Decisions" \ "Morality" \ "Eigenvalues" \ "Overall") ///
	cti("Overplacement", "Component 1", "Component 2", "Component 3", "Unexplained", "KMO") ///
	tex frag replace
	
	
	


	

	
	